winlayout.cxx (248a599f) winlayout.cxx (438f3012)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 401 unchanged lines hidden (view full) ---

410 for( i = 0; i < mnGlyphCount; ++i )
411 {
412 // get the current UCS-4 code point, check for surrogate pairs
413 const WCHAR* pCodes = reinterpret_cast<LPCWSTR>(&pBidiStr[i]);
414 unsigned nCharCode = pCodes[0];
415 bool bSurrogate = ((nCharCode >= 0xD800) && (nCharCode <= 0xDFFF));
416 if( bSurrogate )
417 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 401 unchanged lines hidden (view full) ---

410 for( i = 0; i < mnGlyphCount; ++i )
411 {
412 // get the current UCS-4 code point, check for surrogate pairs
413 const WCHAR* pCodes = reinterpret_cast<LPCWSTR>(&pBidiStr[i]);
414 unsigned nCharCode = pCodes[0];
415 bool bSurrogate = ((nCharCode >= 0xD800) && (nCharCode <= 0xDFFF));
416 if( bSurrogate )
417 {
418 if( nCharCode >= 0xDC00 ) // this part of a surrogate pair was already processed
418 // ignore high surrogates, they were already processed with their low surrogates
419 if( nCharCode >= 0xDC00 )
419 continue;
420 continue;
420 nCharCode = 0x10000 + ((pCodes[0] - 0xD800) << 10) + (pCodes[1] - 0xDC00);
421 }
421 // check the second half of the surrogate pair
422 bSurrogate &= (0xDC00 <= pCodes[1]) && (pCodes[1] <= 0xDFFF);
423 // calculate the UTF-32 code of valid surrogate pairs
424 if( bSurrogate )
425 nCharCode = 0x10000 + ((pCodes[0] - 0xD800) << 10) + (pCodes[1] - 0xDC00);
426 else // or fall back to a replacement character
427 nCharCode = '?';
428 }
422
429
423 // get the advance width for the current UCS-4 code point
430 // get the advance width for the current UTF-32 code point
424 int nGlyphWidth = mrWinFontEntry.GetCachedGlyphWidth( nCharCode );
425 if( nGlyphWidth == -1 )
426 {
427 ABC aABC;
428 SIZE aExtent;
429 if( ::GetTextExtentPoint32W( mhDC, &pCodes[0], bSurrogate ? 2 : 1, &aExtent) )
430 nGlyphWidth = aExtent.cx;
431 else if( ::GetCharABCWidthsW( mhDC, nCharCode, nCharCode, &aABC ) )
432 nGlyphWidth = aABC.abcA + aABC.abcB + aABC.abcC;
433 else if( !::GetCharWidth32W( mhDC, nCharCode, nCharCode, &nGlyphWidth )
434 && !::GetCharWidthW( mhDC, nCharCode, nCharCode, &nGlyphWidth ) )
435 nGlyphWidth = 0;
436 mrWinFontEntry.CacheGlyphWidth( nCharCode, nGlyphWidth );
437 }
438 mpGlyphAdvances[ i ] = nGlyphWidth;
439 mnWidth += nGlyphWidth;
440
431 int nGlyphWidth = mrWinFontEntry.GetCachedGlyphWidth( nCharCode );
432 if( nGlyphWidth == -1 )
433 {
434 ABC aABC;
435 SIZE aExtent;
436 if( ::GetTextExtentPoint32W( mhDC, &pCodes[0], bSurrogate ? 2 : 1, &aExtent) )
437 nGlyphWidth = aExtent.cx;
438 else if( ::GetCharABCWidthsW( mhDC, nCharCode, nCharCode, &aABC ) )
439 nGlyphWidth = aABC.abcA + aABC.abcB + aABC.abcC;
440 else if( !::GetCharWidth32W( mhDC, nCharCode, nCharCode, &nGlyphWidth )
441 && !::GetCharWidthW( mhDC, nCharCode, nCharCode, &nGlyphWidth ) )
442 nGlyphWidth = 0;
443 mrWinFontEntry.CacheGlyphWidth( nCharCode, nGlyphWidth );
444 }
445 mpGlyphAdvances[ i ] = nGlyphWidth;
446 mnWidth += nGlyphWidth;
447
441 // remaining codes of surrogate pair get a zero width
448 // the second half of surrogate pair gets a zero width
442 if( bSurrogate && ((i+1) < mnGlyphCount) )
443 mpGlyphAdvances[ i+1 ] = 0;
444
445 // check with the font face if glyph fallback is needed
446 if( mrWinFontData.HasChar( nCharCode ) )
447 continue;
448
449 // request glyph fallback at this position in the string

--- 2740 unchanged lines hidden ---
449 if( bSurrogate && ((i+1) < mnGlyphCount) )
450 mpGlyphAdvances[ i+1 ] = 0;
451
452 // check with the font face if glyph fallback is needed
453 if( mrWinFontData.HasChar( nCharCode ) )
454 continue;
455
456 // request glyph fallback at this position in the string

--- 2740 unchanged lines hidden ---