@@ -305,6 +305,34 @@ FtfdGetFontInstance(
305
305
return pfont ;
306
306
}
307
307
308
+ static
309
+ BOOL
310
+ FtfdLoadGlyph (
311
+ PFTFD_FONT pfont ,
312
+ HGLYPH hg ,
313
+ ULONG iFormat ) // 0 = bitmap, 1 = outline
314
+ {
315
+ FT_Error fterror ;
316
+
317
+ /* Check if the glyph needs to be updated */
318
+ if (pfont -> hgSelected != hg )
319
+ {
320
+ /* Load the glyph into the freetype face slot */
321
+ fterror = FT_Load_Glyph (pfont -> ftface , hg , 0 );
322
+ if (fterror )
323
+ {
324
+ WARN ("Couldn't load glyph 0x%lx\n" , hg );
325
+ pfont -> hgSelected = -1 ;
326
+ return FALSE;
327
+ }
328
+
329
+ /* Update the selected glyph */
330
+ pfont -> hgSelected = hg ;
331
+ }
332
+
333
+ return TRUE;
334
+ }
335
+
308
336
ULONG
309
337
NTAPI
310
338
FtfdQueryMaxExtents (
@@ -331,11 +359,28 @@ FtfdQueryMaxExtents(
331
359
/* Accelerator flags (ignored atm) */
332
360
pfddm -> flRealizedType = 0 ;
333
361
334
- /* Set fixed width advance */
362
+ /* Check for fixed width font */
335
363
if (FT_IS_FIXED_WIDTH (ftface ))
336
- pfddm -> lD = ftface -> max_advance_width ;
364
+ {
365
+ /* Make sure a glyph is loaded */
366
+ if ((pfont -> hgSelected != -1 ) ||
367
+ FtfdLoadGlyph (pfont , 0 , 0 ))
368
+ {
369
+ /* Convert advance from 26.6 fixpoint to pixel format */
370
+ pfddm -> lD = pface -> ftface -> glyph -> advance .x >> 6 ;
371
+ }
372
+ else
373
+ {
374
+ /* Fall back to dynamic pitch */
375
+ WARN ("Couldn't load a glyph\n" );
376
+ pfddm -> lD = 0 ;
377
+ }
378
+ }
337
379
else
380
+ {
381
+ /* Variable pitch */
338
382
pfddm -> lD = 0 ;
383
+ }
339
384
340
385
/* Copy some values from the font structure */
341
386
pfddm -> fxMaxAscender = pfont -> metrics .fxMaxAscender ;
@@ -380,33 +425,6 @@ FtfdQueryMaxExtents(
380
425
return sizeof (FD_DEVICEMETRICS );
381
426
}
382
427
383
- static
384
- BOOL
385
- FtfdLoadGlyph (
386
- PFTFD_FONT pfont ,
387
- HGLYPH hg ,
388
- ULONG iFormat ) // 0 = bitmap, 1 = outline
389
- {
390
- FT_Error fterror ;
391
-
392
- /* Check if the glyph needs to be updated */
393
- if (pfont -> hgSelected != hg )
394
- {
395
- /* Load the glyph into the freetype face slot */
396
- fterror = FT_Load_Glyph (pfont -> ftface , hg , 0 );
397
- if (fterror )
398
- {
399
- WARN ("Couldn't load glyph 0x%lx\n" , hg );
400
- pfont -> hgSelected = -1 ;
401
- return FALSE;
402
- }
403
-
404
- /* Update the selected glyph */
405
- pfont -> hgSelected = hg ;
406
- }
407
-
408
- return TRUE;
409
- }
410
428
411
429
static
412
430
VOID
@@ -436,8 +454,8 @@ FtfdQueryGlyphData(
436
454
pgd -> fxAB = pgd -> fxA + ftglyph -> metrics .height ;
437
455
}
438
456
439
- /* D is the glyph advance width */
440
- pgd -> fxD = ftglyph -> advance .x / 4 ; // FIXME: should be projected on the x-axis
457
+ /* D is the glyph advance width. Convert it from 26.6 to 28.4 fixpoint format */
458
+ pgd -> fxD = ftglyph -> advance .x >> 2 ; // FIXME: should be projected on the x-axis
441
459
442
460
/* Get the bitnmap size */
443
461
sizlBitmap .cx = ftglyph -> bitmap .width ;
0 commit comments