History

ComponentGlyf reader: fix F2DOT14 parsing

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit 1d352251 parent 96da9f02 files · +18 −14Browse files

Unified · Split

2 files
  1. otf.c.in +9 −7
  2. plan9/otf.c +9 −7
otf.c.in+9−7
@@ -264,6 +264,7 @@ read_ComponentGlyph(Otf *o, ComponentGlyph **out, int instr) · 263 unmodified lines
264{264{
265 ComponentGlyph *v;265 ComponentGlyph *v;
266 u8int *b;266 u8int *b;
267 s16int f;
267 268
268 if((v = calloc(1, sizeof(*v))) == nil){269 if((v = calloc(1, sizeof(*v))) == nil){
269nomem:270nomem:
@@ -296,16 +297,17 @@ nomem: · 26 unmodified lines
296 }297 }
297 if(b == nil)298 if(b == nil)
298 goto err;299 goto err;
300 #define f2dot14(o) (f = b[2*o]<<8 | b[2*o+1], (f>>14)+(f&((1<<14)-1))/16384.0)
299 if((v->flags & CGLYPH_FL_SCALE) != 0 && (b = otfreadn(o, 2)) != nil){301 if((v->flags & CGLYPH_FL_SCALE) != 0 && (b = otfreadn(o, 2)) != nil){
300 v->scale = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;302 v->scale = f2dot14(0);
301 }else if((v->flags & CGLYPH_FL_SCALE_XY) != 0 && (b = otfreadn(o, 2*2)) != nil){303 }else if((v->flags & CGLYPH_FL_SCALE_XY) != 0 && (b = otfreadn(o, 2*2)) != nil){
302 v->scaleX = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;304 v->scaleX = f2dot14(0);
303 v->scaleY = (b[2]<<8 | b[3]>>14)+(b[2]<<8 | b[3]&((1<<14)-1))/16384.0;305 v->scaleY = f2dot14(1);
304 }else if((v->flags & CGLYPH_FL_2X2_TRANSFORM) != 0 && (b = otfreadn(o, 2*2*2)) != nil){306 }else if((v->flags & CGLYPH_FL_2X2_TRANSFORM) != 0 && (b = otfreadn(o, 2*2*2)) != nil){
305 v->scaleX = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;307 v->scaleX = f2dot14(0);
306 v->scale01 = (b[2]<<8 | b[3]>>14)+(b[2]<<8 | b[3]&((1<<14)-1))/16384.0;308 v->scale01 = f2dot14(1);
307 v->scale10 = (b[4]<<8 | b[5]>>14)+(b[4]<<8 | b[5]&((1<<14)-1))/16384.0;309 v->scale10 = f2dot14(2);
308 v->scaleY = (b[6]<<8 | b[7]>>14)+(b[6]<<8 | b[7]&((1<<14)-1))/16384.0;310 v->scaleY = f2dot14(3);
309 }311 }
310 if(b == nil)312 if(b == nil)
311 goto err;313 goto err;
plan9/otf.c+9−7
@@ -278,6 +278,7 @@ read_ComponentGlyph(Otf *o, ComponentGlyph **out, int instr) · 277 unmodified lines
278{278{
279 ComponentGlyph *v;279 ComponentGlyph *v;
280 u8int *b;280 u8int *b;
281 s16int f;
281 282
282 if((v = calloc(1, sizeof(*v))) == nil){283 if((v = calloc(1, sizeof(*v))) == nil){
283nomem:284nomem:
@@ -310,16 +311,17 @@ nomem: · 26 unmodified lines
310 }311 }
311 if(b == nil)312 if(b == nil)
312 goto err;313 goto err;
314 #define f2dot14(o) (f = b[2*o]<<8 | b[2*o+1], (f>>14)+(f&((1<<14)-1))/16384.0)
313 if((v->flags & CGLYPH_FL_SCALE) != 0 && (b = otfreadn(o, 2)) != nil){315 if((v->flags & CGLYPH_FL_SCALE) != 0 && (b = otfreadn(o, 2)) != nil){
314 v->scale = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;316 v->scale = f2dot14(0);
315 }else if((v->flags & CGLYPH_FL_SCALE_XY) != 0 && (b = otfreadn(o, 2*2)) != nil){317 }else if((v->flags & CGLYPH_FL_SCALE_XY) != 0 && (b = otfreadn(o, 2*2)) != nil){
316 v->scaleX = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;318 v->scaleX = f2dot14(0);
317 v->scaleY = (b[2]<<8 | b[3]>>14)+(b[2]<<8 | b[3]&((1<<14)-1))/16384.0;319 v->scaleY = f2dot14(1);
318 }else if((v->flags & CGLYPH_FL_2X2_TRANSFORM) != 0 && (b = otfreadn(o, 2*2*2)) != nil){320 }else if((v->flags & CGLYPH_FL_2X2_TRANSFORM) != 0 && (b = otfreadn(o, 2*2*2)) != nil){
319 v->scaleX = (b[0]<<8 | b[1]>>14)+(b[0]<<8 | b[1]&((1<<14)-1))/16384.0;321 v->scaleX = f2dot14(0);
320 v->scale01 = (b[2]<<8 | b[3]>>14)+(b[2]<<8 | b[3]&((1<<14)-1))/16384.0;322 v->scale01 = f2dot14(1);
321 v->scale10 = (b[4]<<8 | b[5]>>14)+(b[4]<<8 | b[5]&((1<<14)-1))/16384.0;323 v->scale10 = f2dot14(2);
322 v->scaleY = (b[6]<<8 | b[7]>>14)+(b[6]<<8 | b[7]&((1<<14)-1))/16384.0;324 v->scaleY = f2dot14(3);
323 }325 }
324 if(b == nil)326 if(b == nil)
325 goto err;327 goto err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t