Changeset 4162

Show
Ignore:
Timestamp:
2006年09月10日 21時52分34秒 (2 years ago)
Author:
fujii
Message:

Fix the calculation of overhang, lbearing and rbearing in non TrueType?
font. See ticket:136.

* mw32font.c (mw32_set_windows_logical_font): Correct the
calculation of overhang in non TrueType? font. See ticket:136.
(mw32_glyph_metric): Correct lbearing and rbearing in non TrueType?
font. See ticket:136.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/ChangeLog.Meadow

    r4161 r4162  
     12006-09-10  Masayuki FUJII  <boochang@m4.kcn.ne.jp> 
     2 
     3        * mw32font.c (mw32_set_windows_logical_font): Correct the 
     4        calculation of overhang in non TrueType font. See ticket:136. 
     5        (mw32_glyph_metric): Correct lbearing and rbearing in non TrueType 
     6        font. See ticket:136. 
     7 
    182006-09-09  MIYOSHI Masanori  <miyoshi@meadowy.org> 
    29 
  • trunk/src/mw32font.c

    r4152 r4162  
    232232            pwf->cur_cm.width = w; 
    233233          } 
    234         pwf->cur_cm.rbearing = 0; 
    235         pwf->cur_cm.lbearing = plf->overhang; 
     234        pwf->cur_cm.rbearing = pwf->cur_cm.width; 
     235        if (pwf->logfont.lfItalic) 
     236          pwf->cur_cm.rbearing += plf->overhang; 
     237        pwf->cur_cm.lbearing = 0; 
    236238      } 
    237239    pwf->cur_cm.ascent = plf->ascent; 
     
    385387 
    386388      pwf->pfont = hf; 
     389      pwf->ttfp = (tm.tmPitchAndFamily & TMPF_TRUETYPE); 
    387390 
    388391      plf->width = tm.tmAveCharWidth; 
     
    390393      plf->ascent = tm.tmAscent; 
    391394      plf->descent = tm.tmHeight - tm.tmAscent; 
    392       plf->overhang = tm.tmOverhang; 
     395 
     396      if (!pwf->ttfp  
     397          && plogf->lfWeight != FW_NORMAL && plogf->lfWeight != FW_DONTCARE) 
     398        { 
     399          HFONT hf_normal; 
     400          LOGFONT logf_normal = *plogf; 
     401 
     402          /* For bold string in non TrueType font, the value of 
     403             overhang includes offset of overstrike. */ 
     404          logf_normal.lfWeight = FW_NORMAL; 
     405 
     406          if (!(hf_normal = CreateFontIndirect (&logf_normal))) 
     407            { 
     408              xfree (pwf); 
     409              return 0; 
     410            } 
     411 
     412          HDC hdc; 
     413          HANDLE oldobj; 
     414          TEXTMETRIC tm_normal; 
     415          int flag; 
     416 
     417          hdc = GET_FRAME_HDC (f); 
     418          oldobj = SelectObject (hdc, hf_normal); 
     419          flag = GetTextMetrics (hdc, &tm_normal); 
     420          SelectObject (hdc, oldobj); 
     421          RELEASE_FRAME_HDC (f); 
     422 
     423          DeleteObject (hf_normal); 
     424 
     425          if (!flag) 
     426            { 
     427              xfree (pwf); 
     428              return 0; 
     429            } 
     430 
     431          plf->overhang = tm_normal.tmOverhang; 
     432        } 
     433      else 
     434        plf->overhang = tm.tmOverhang; 
     435 
    393436      plf->fixed_pitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH); 
    394437      mw32_windows_set_logical_font_from_char (plf, c); 
     
    397440      plf->character_spacing = 0; 
    398441      plf->centering = 0; 
    399  
    400       pwf->ttfp = (tm.tmPitchAndFamily & TMPF_TRUETYPE); 
    401442    } 
    402443  else