Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b2f6fb

Browse files
committed
Support scale in ttf composite glyphs
Fixes#17197
1 parent3e439a4 commit5b2f6fb

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

‎extern/ttconv/pprdrv_tt.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ Fixed getFixed(BYTE *s)
107107
return val;
108108
}/* end of getFixed()*/
109109

110+
/*
111+
** Get a 16 bit fixed point (2.14) number.
112+
*/
113+
F2DOT14getF2DOT14(BYTE *s)
114+
{
115+
F2DOT14 val={0,0};
116+
117+
int sign = s[0] &0x80;
118+
int bit = (s[0] &0x40) >>6;
119+
if (sign) {
120+
val.whole = bit-2;
121+
}else {
122+
val.whole = bit;
123+
}
124+
val.fraction = ((s[0] &0x3f) <<8) + s[1];
125+
126+
return val;
127+
}
128+
129+
floatF2DOT14value(F2DOT14 f)
130+
{
131+
return f.whole + (float)f.fraction/16384;
132+
}
133+
134+
110135
/*-----------------------------------------------------------------------
111136
** Load a TrueType font table into memory and return a pointer to it.
112137
** The font's "file" and "offset_table" fields must be set before this

‎extern/ttconv/pprdrv_tt2.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ void GlyphToType3::do_composite(TTStreamWriter& stream, struct TTFONT *font, BYT
417417
USHORT glyphIndex;
418418
int arg1;
419419
int arg2;
420+
F2DOT14 mat00 = {1,0}, mat01 = {0,0}, mat10 = {0,0}, mat11 = {1,0};
420421

421422
/* Once around this loop for each component.*/
422423
do
@@ -444,14 +445,21 @@ void GlyphToType3::do_composite(TTStreamWriter& stream, struct TTFONT *font, BYT
444445

445446
if (flags & WE_HAVE_A_SCALE)
446447
{
448+
mat00 = mat11 =getF2DOT14(glyph);
447449
glyph +=2;
448450
}
449451
elseif (flags & WE_HAVE_AN_X_AND_Y_SCALE)
450452
{
453+
mat00 =getF2DOT14(glyph);
454+
mat11 =getF2DOT14(glyph+2);
451455
glyph +=4;
452456
}
453457
elseif (flags & WE_HAVE_A_TWO_BY_TWO)
454458
{
459+
mat00 =getF2DOT14(glyph);
460+
mat01 =getF2DOT14(glyph+2);
461+
mat10 =getF2DOT14(glyph+4);
462+
mat11 =getF2DOT14(glyph+6);
455463
glyph +=8;
456464
}
457465
else
@@ -472,7 +480,10 @@ void GlyphToType3::do_composite(TTStreamWriter& stream, struct TTFONT *font, BYT
472480
subglyph here. However, that doesn't seem to work with
473481
xpdf or gs (only acrobat), so instead, this just includes
474482
the subglyph here inline.*/
475-
stream.printf("q 1 0 0 1 %d %d cm\n",topost(arg1),topost(arg2));
483+
stream.printf("q %.6f %.6f %.6f %.6f %d %d cm\n",
484+
F2DOT14value(mat00),F2DOT14value(mat01),
485+
F2DOT14value(mat10),F2DOT14value(mat11),
486+
topost(arg1),topost(arg2));
476487
}
477488
else
478489
{

‎extern/ttconv/truetype.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ typedef struct
4141
unsigned shortintfraction;
4242
}Fixed;
4343

44+
/* A 2.14 fixed point number */
45+
typedefstruct
46+
{
47+
SHORTwhole;
48+
USHORTfraction;
49+
}F2DOT14;
50+
4451
/* This structure tells what we have found out about */
4552
/* the current font. */
4653
structTTFONT
@@ -86,6 +93,8 @@ struct TTFONT
8693
ULONGgetULONG(BYTE*p);
8794
USHORTgetUSHORT(BYTE*p);
8895
FixedgetFixed(BYTE*p);
96+
F2DOT14getF2DOT14(BYTE*p);
97+
floatF2DOT14value(F2DOT14f);
8998

9099
/*
91100
** Get an funits word.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp