Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/harfbuzz/src/harfbuzz-open.c

Issue 7595001: Update (old) harfbuzz to ToT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg 2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
3 * Copyright (C) 2006 Behdad Esfahbod 3 * Copyright (C) 2006 Behdad Esfahbod
4 * 4 *
5 * This is part of HarfBuzz, an OpenType Layout engine library. 5 * This is part of HarfBuzz, an OpenType Layout engine library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1275 }
1276 1276
1277 1277
1278 1278
1279 /*************************** 1279 /***************************
1280 * Device related functions 1280 * Device related functions
1281 ***************************/ 1281 ***************************/
1282 1282
1283 1283
1284 HB_INTERNAL HB_Error 1284 HB_INTERNAL HB_Error
1285 _HB_OPEN_Load_Device( HB_Device* d, 1285 _HB_OPEN_Load_Device( HB_Device** device,
1286 HB_Stream stream ) 1286 HB_Stream stream )
1287 { 1287 {
1288 HB_Device* d;
1288 HB_Error error; 1289 HB_Error error;
1289 1290
1290 HB_UShort n, count; 1291 HB_UShort n, count;
1291 1292
1292 HB_UShort* dv; 1293 HB_UShort* dv;
1293 1294
1294 1295
1295 if ( ACCESS_Frame( 6L ) ) 1296 if ( ACCESS_Frame( 6L ) )
1296 return error; 1297 return error;
1297 1298
1299 if ( ALLOC( *device, sizeof(HB_Device)) )
1300 {
1301 *device = 0;
1302 return error;
1303 }
1304
1305 d = *device;
1306
1298 d->StartSize = GET_UShort(); 1307 d->StartSize = GET_UShort();
1299 d->EndSize = GET_UShort(); 1308 d->EndSize = GET_UShort();
1300 d->DeltaFormat = GET_UShort(); 1309 d->DeltaFormat = GET_UShort();
1301 1310
1302 FORGET_Frame(); 1311 FORGET_Frame();
1303 1312
1304 d->DeltaValue = NULL; 1313 d->DeltaValue = NULL;
1305 1314
1306 if ( d->StartSize > d->EndSize || 1315 if ( d->StartSize > d->EndSize ||
1307 d->DeltaFormat == 0 || d->DeltaFormat > 3 ) 1316 d->DeltaFormat == 0 || d->DeltaFormat > 3 )
1308 { 1317 {
1309 /* XXX 1318 /* XXX
1310 * I've seen fontforge generate DeltaFormat == 0. 1319 * I've seen fontforge generate DeltaFormat == 0.
1311 * Just return Ok and let the NULL DeltaValue disable 1320 * Just return Ok and let the NULL DeltaValue disable
1312 * this table. 1321 * this table.
1313 */ 1322 */
1314 return HB_Err_Ok; 1323 return HB_Err_Ok;
1315 } 1324 }
1316 1325
1317 count = ( ( d->EndSize - d->StartSize + 1 ) >> 1326 count = ( ( d->EndSize - d->StartSize + 1 ) >>
1318 ( 4 - d->DeltaFormat ) ) + 1; 1327 ( 4 - d->DeltaFormat ) ) + 1;
1319 1328
1320 if ( ALLOC_ARRAY( d->DeltaValue, count, HB_UShort ) ) 1329 if ( ALLOC_ARRAY( d->DeltaValue, count, HB_UShort ) )
1330 {
1331 FREE( *device );
1332 *device = 0;
1321 return error; 1333 return error;
1334 }
1322 1335
1323 if ( ACCESS_Frame( count * 2L ) ) 1336 if ( ACCESS_Frame( count * 2L ) )
1324 { 1337 {
1325 FREE( d->DeltaValue ); 1338 FREE( d->DeltaValue );
1339 FREE( *device );
1340 *device = 0;
1326 return error; 1341 return error;
1327 } 1342 }
1328 1343
1329 dv = d->DeltaValue; 1344 dv = d->DeltaValue;
1330 1345
1331 for ( n = 0; n < count; n++ ) 1346 for ( n = 0; n < count; n++ )
1332 dv[n] = GET_UShort(); 1347 dv[n] = GET_UShort();
1333 1348
1334 FORGET_Frame(); 1349 FORGET_Frame();
1335 1350
1336 return HB_Err_Ok; 1351 return HB_Err_Ok;
1337 } 1352 }
1338 1353
1339 1354
1340 HB_INTERNAL void 1355 HB_INTERNAL void
1341 _HB_OPEN_Free_Device( HB_Device* d ) 1356 _HB_OPEN_Free_Device( HB_Device* d )
1342 { 1357 {
1343 FREE( d->DeltaValue ); 1358 if ( d )
1359 {
1360 FREE( d->DeltaValue );
1361 FREE( d );
1362 }
1344 } 1363 }
1345 1364
1346 1365
1347 /* Since we have the delta values stored in compressed form, we must 1366 /* Since we have the delta values stored in compressed form, we must
1348 uncompress it now. To simplify the interface, the function always 1367 uncompress it now. To simplify the interface, the function always
1349 returns a meaningful value in `value'; the error is just for 1368 returns a meaningful value in `value'; the error is just for
1350 information. 1369 information.
1351 | | 1370 | |
1352 format = 1: 0011223344556677|8899101112131415|... 1371 format = 1: 0011223344556677|8899101112131415|...
1353 | | 1372 | |
(...skipping 23 matching lines...) Expand all
1377 11111111: (byte >> 0) & mask 1396 11111111: (byte >> 0) & mask
1378 .... 1397 ....
1379 1398
1380 mask = 0x00FF */ 1399 mask = 0x00FF */
1381 1400
1382 HB_INTERNAL HB_Error 1401 HB_INTERNAL HB_Error
1383 _HB_OPEN_Get_Device( HB_Device* d, 1402 _HB_OPEN_Get_Device( HB_Device* d,
1384 HB_UShort size, 1403 HB_UShort size,
1385 HB_Short* value ) 1404 HB_Short* value )
1386 { 1405 {
1387 HB_UShort byte, bits, mask, f, s; 1406 HB_UShort byte, bits, mask, s;
1388 1407
1389 1408 if ( d && d->DeltaValue && size >= d->StartSize && size <= d->EndSize )
1390 f = d->DeltaFormat;
1391
1392 if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize )
1393 { 1409 {
1410 HB_UShort f = d->DeltaFormat;
1394 s = size - d->StartSize; 1411 s = size - d->StartSize;
1395 byte = d->DeltaValue[s >> ( 4 - f )]; 1412 byte = d->DeltaValue[s >> ( 4 - f )];
1396 bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) ); 1413 bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) );
1397 mask = 0xFFFF >> ( 16 - ( 1 << f ) ); 1414 mask = 0xFFFF >> ( 16 - ( 1 << f ) );
1398 1415
1399 *value = (HB_Short)( bits & mask ); 1416 *value = (HB_Short)( bits & mask );
1400 1417
1401 /* conversion to a signed value */ 1418 /* conversion to a signed value */
1402 1419
1403 if ( *value >= ( ( mask + 1 ) >> 1 ) ) 1420 if ( *value >= ( ( mask + 1 ) >> 1 ) )
1404 *value -= mask + 1; 1421 *value -= mask + 1;
1405 1422
1406 return HB_Err_Ok; 1423 return HB_Err_Ok;
1407 } 1424 }
1408 else 1425 else
1409 { 1426 {
1410 *value = 0; 1427 *value = 0;
1411 return HB_Err_Not_Covered; 1428 return HB_Err_Not_Covered;
1412 } 1429 }
1413 } 1430 }
1414 1431
1415 1432
1416 /* END */ 1433 /* END */
OLDNEW
« no previous file with comments | « third_party/harfbuzz/src/harfbuzz-open.h ('k') | third_party/harfbuzz/src/harfbuzz-open-private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698