View | Details | Raw Unified | Return to issue 63637
Collapse All | Expand All

(-)OOB680_m5.orig/vcl/inc/outdev.h (+8 lines)
Lines 96-101 public: Link Here
96
    void                UpdateDevFontList( ImplGetDevFontList& ) const;
96
    void                UpdateDevFontList( ImplGetDevFontList& ) const;
97
    void                UpdateCloneFontList( ImplDevFontList&,
97
    void                UpdateCloneFontList( ImplDevFontList&,
98
                            bool bScalable, bool bEmbeddable ) const;
98
                            bool bScalable, bool bEmbeddable ) const;
99
    // Add by Firefly(firefly@ossii.com.tw)
100
    // 所屬的字體群組(參考 ImplDevFontList::maGroupFontList)
101
    void		SetGroupID(const int nID) { mnGroupID=nID; }
102
    int			GetGroupID() const { return mnGroupID; };
99
103
100
private:
104
private:
101
friend class ImplDevFontList; // TODO: remove soon
105
friend class ImplDevFontList; // TODO: remove soon
Lines 111-116 friend class ImplDevFontList; // TODO: r Link Here
111
    FontFamily          meFamily;
115
    FontFamily          meFamily;
112
    FontPitch           mePitch;
116
    FontPitch           mePitch;
113
    int                 mnMinQuality;       // quality of the worst font face
117
    int                 mnMinQuality;       // quality of the worst font face
118
    // Add by Firefly(firefly@ossii.com.tw)
119
    // 所屬的字體群組(參考 ImplDevFontList::maGroupFontList)
120
    // -1 表示沒有所屬群組
121
    int			mnGroupID;
114
};
122
};
115
123
116
124
(-)OOB680_m5.orig/vcl/inc/outfont.hxx (+14 lines)
Lines 230-235 public: Link Here
230
    bool                    HasFallbacks() const;
230
    bool                    HasFallbacks() const;
231
    void                    SetFallbacks( ImplDevFontListData**, int nCount );
231
    void                    SetFallbacks( ImplDevFontListData**, int nCount );
232
    ImplDevFontListData*    GetFallback( int nIndex ) const;
232
    ImplDevFontListData*    GetFallback( int nIndex ) const;
233
    // Add by Firefly(firefly@ossii.com.tw)
234
    int                     GetFallbackCount() const {return mnFallbackCount;}
235
    int                     ImplCheckGroupID( const String&, const String& ) const;
236
    bool                    SetFallbackByGroupID( const int nGroupID );
237
    //----------------------------------------------------------------
233
238
234
    ImplDevFontList*        Clone( bool bScalable, bool bEmbeddable ) const;
239
    ImplDevFontList*        Clone( bool bScalable, bool bEmbeddable ) const;
235
    ImplGetDevFontList*     GetDevFontList() const;
240
    ImplGetDevFontList*     GetDevFontList() const;
Lines 245-254 protected: Link Here
245
    ImplDevFontListData*    ImplFindByAttributes( ULONG nSearchType, FontWeight, FontWidth,
250
    ImplDevFontListData*    ImplFindByAttributes( ULONG nSearchType, FontWeight, FontWidth,
246
                                FontFamily, FontItalic, const String& rSearchFamily ) const;
251
                                FontFamily, FontItalic, const String& rSearchFamily ) const;
247
    ImplDevFontListData*    FindDefaultFont() const;
252
    ImplDevFontListData*    FindDefaultFont() const;
253
    // Add by Firefly(firefly@ossii.com.tw)
254
    void		    AddFontGroup(const String);
255
    ImplDevFontListData*    ImplFindByGroupName( const String& ) const;
256
    //----------------------------------------------------------------
248
257
249
private:
258
private:
250
    ImplDevFontListData**   mpFallbackList;
259
    ImplDevFontListData**   mpFallbackList;
251
    int                     mnFallbackCount;
260
    int                     mnFallbackCount;
261
    // Add by Firefly(firefly@ossii.com.tw)
262
    typedef std::vector<String> GroupFontList;
263
    GroupFontList           maGroupFontList;
264
    int                     mnLastSortID;
265
    //----------------------------------------
252
};
266
};
253
267
254
268
(-)OOB680_m5.orig/vcl/inc/sallayout.hxx (+4 lines)
Lines 269-274 public: Link Here
269
    virtual bool    GetBoundRect( SalGraphics&, Rectangle& ) const;
269
    virtual bool    GetBoundRect( SalGraphics&, Rectangle& ) const;
270
270
271
    // used only by OutputDevice::ImplLayout, TODO: make friend
271
    // used only by OutputDevice::ImplLayout, TODO: make friend
272
    // Add by Firefly(firefly@ossii.com.tw)
273
    // OK. I have been defined.
274
    friend class OutputDevice;
275
    //--------------------------------------------
272
                    MultiSalLayout( SalLayout& rBaseLayout );   // transfer ownership
276
                    MultiSalLayout( SalLayout& rBaseLayout );   // transfer ownership
273
    virtual bool    AddFallback( SalLayout& rFallback,          // transfer ownership
277
    virtual bool    AddFallback( SalLayout& rFallback,          // transfer ownership
274
                         ImplLayoutRuns& rRuns, ImplFontData* pFallbackFont );
278
                         ImplLayoutRuns& rRuns, ImplFontData* pFallbackFont );
(-)OOB680_m5.orig/vcl/source/gdi/outdev3.cxx (-7 / +426 lines)
Lines 376-381 void OutputDevice::ImplUpdateAllFontData Link Here
376
376
377
// =======================================================================
377
// =======================================================================
378
378
379
// Add by Firefly(firefly@ossii.com.tw)
380
static char *aDefaultGroup = \
381
"仿|" \
382
"明;宋;Ming;Sung;Song|" \
383
"楷;Kai|" \
384
"隸;隶|" \
385
"黑;Hei|" \
386
"圓;圆|" \
387
"行書;行书|勘亭流|古印|魏碑|" \
388
"鋼筆;钢笔|" \
389
"新藝;新艺|綜藝;综艺|海報;海报|空疊;空叠|疊圓;叠圆|廣告;广告|POP|" \
390
"手寫;手写|注音|" \
391
"symbol;Symbol;Webdings;Dingbats";
392
/*
393
"超明|特明|粗明;粗宋|中明;中宋|粗仿|中仿|仿宋|明;宋;Ming;Sung;Song|" \
394
"粗隸;粗隶|中隸;中隶|隸;隶|" \
395
"超黑|特黑|粗黑|中黑|黑;Hei|" \
396
"超圓;超圆|特圓;特圆|粗圓;粗圆|中圓;中圆|圓;圆|" \
397
"行書;行书|勘亭流|古印|魏碑|顏楷;颜楷|毛楷|行楷|粗楷|中楷|楷;Kai|" \
398
"粗鋼筆;粗钢笔|中鋼筆;中钢笔|鋼筆;钢笔|" \
399
"新藝;新艺|綜藝;综艺|海報;海报|空疊;空叠|疊圓;叠圆|廣告;广告|POP|" \
400
"手寫;手写|注音|" \
401
"Symbol;Webdings;Dingbats";
402
*/
403
// Disable by Firefly(firefly@ossii.com.tw)
404
// 我看不出來有何理由要轉換 localized name.
405
#if 0
379
struct ImplLocalizedFontName
406
struct ImplLocalizedFontName
380
{
407
{
381
    const char*         mpEnglishName;
408
    const char*         mpEnglishName;
Lines 647-652 static ImplLocalizedFontName aImplLocali Link Here
647
{   "hgmarugothicmpro",     aHGMaruGothicMPRO },
674
{   "hgmarugothicmpro",     aHGMaruGothicMPRO },
648
{   NULL,                   NULL },
675
{   NULL,                   NULL },
649
};
676
};
677
#endif
650
678
651
// -----------------------------------------------------------------------
679
// -----------------------------------------------------------------------
652
680
Lines 736-741 void ImplGetEnglishSearchFontName( Strin Link Here
736
        i++;
764
        i++;
737
    }
765
    }
738
766
767
// Disable by Firefly(firefly@ossii.com.tw)
768
// 我看不出來有何理由要轉換 localized name.
769
#if 0
739
    // translate normalized localized name to its normalized English ASCII name
770
    // translate normalized localized name to its normalized English ASCII name
740
    if( bNeedTranslation )
771
    if( bNeedTranslation )
741
    {
772
    {
Lines 754-759 void ImplGetEnglishSearchFontName( Strin Link Here
754
        if( it != aDictionary.end() )
785
        if( it != aDictionary.end() )
755
            rName.AssignAscii( it->second );
786
            rName.AssignAscii( it->second );
756
    }
787
    }
788
#endif
757
}
789
}
758
790
759
// -----------------------------------------------------------------------
791
// -----------------------------------------------------------------------
Lines 1567-1572 ImplDevFontListData::ImplDevFontListData Link Here
1567
    meMatchWidth( WIDTH_DONTKNOW ),
1599
    meMatchWidth( WIDTH_DONTKNOW ),
1568
    mnTypeFaces( 0 ),
1600
    mnTypeFaces( 0 ),
1569
    mnMatchType( 0 ),
1601
    mnMatchType( 0 ),
1602
    // Add by Firefly(firefly@ossii.com.tw)
1603
    // 預設沒有所屬群組
1604
    mnGroupID( -1 ),
1570
    mnMinQuality( -1 )
1605
    mnMinQuality( -1 )
1571
{}
1606
{}
1572
1607
Lines 1614-1622 bool ImplDevFontListData::AddFontFace( I Link Here
1614
        mnTypeFaces |= IMPL_DEVFONT_SCALABLE;
1649
        mnTypeFaces |= IMPL_DEVFONT_SCALABLE;
1615
1650
1616
    if( pNewData->IsSymbolFont() )
1651
    if( pNewData->IsSymbolFont() )
1652
    {
1617
        mnTypeFaces |= IMPL_DEVFONT_SYMBOL;
1653
        mnTypeFaces |= IMPL_DEVFONT_SYMBOL;
1654
    }
1618
    else
1655
    else
1656
    {
1619
        mnTypeFaces |= IMPL_DEVFONT_NONESYMBOL;
1657
        mnTypeFaces |= IMPL_DEVFONT_NONESYMBOL;
1658
	// Add by Firefly(firefly@ossii.com.tw)
1659
	// 中日韓字體優先
1660
	// Check is CJK font?
1661
	String aCheckName = pNewData->maName;
1662
	if (pNewData->maMapNames.Len())
1663
	    aCheckName.Append(pNewData->maMapNames);
1664
1665
	const unsigned nIsCJK = ImplIsCJKFont(aCheckName);
1666
	if (nIsCJK & IMPL_FONT_ATTR_CJK)
1667
	    mnMinQuality += 100000000;
1668
	//-------------------------------------------------
1669
    }
1620
1670
1621
    if( pNewData->meWeight != WEIGHT_DONTKNOW )
1671
    if( pNewData->meWeight != WEIGHT_DONTKNOW )
1622
    {
1672
    {
Lines 1780-1785 ImplDevFontList::ImplDevFontList() Link Here
1780
    mbMapNames  = false;
1830
    mbMapNames  = false;
1781
    mpFallbackList  = NULL;
1831
    mpFallbackList  = NULL;
1782
    mnFallbackCount = -1;
1832
    mnFallbackCount = -1;
1833
    // Add by Firefly(firefly@ossii.com.tw)
1834
    mnLastSortID = -99;
1835
    const char *pEnv = getenv("OOO_FONT_GROUP_LIST");
1836
    // 使用者定義優先處理
1837
    if (pEnv)
1838
    {
1839
	String aGroupName(pEnv, RTL_TEXTENCODING_UTF8);
1840
	AddFontGroup(aGroupName);
1841
    }
1842
    String aDefault(aDefaultGroup, RTL_TEXTENCODING_UTF8);
1843
    AddFontGroup(aDefault);
1844
    //-----------------------------------------------------
1783
}
1845
}
1784
1846
1785
// -----------------------------------------------------------------------
1847
// -----------------------------------------------------------------------
Lines 1808-1813 void ImplDevFontList::Clear() Link Here
1808
1870
1809
    maDevFontList.clear();
1871
    maDevFontList.clear();
1810
1872
1873
    // Add by Firefly(firefly@ossii.com.tw)
1874
    maGroupFontList.clear();
1875
    mnLastSortID = -99;
1876
1811
    // match data must be recalculated too
1877
    // match data must be recalculated too
1812
    mbMatchData = false;
1878
    mbMatchData = false;
1813
}
1879
}
Lines 1866-1872 void ImplDevFontList::Add( ImplFontData* Link Here
1866
{
1932
{
1867
    int nAliasQuality = pNewData->mnQuality - 100;
1933
    int nAliasQuality = pNewData->mnQuality - 100;
1868
    String aMapNames = pNewData->maMapNames;
1934
    String aMapNames = pNewData->maMapNames;
1869
    pNewData->maMapNames = String();
1935
    // Modify by Firefly(firefly@firefly.idv.tw)
1936
    // Don't clean maMapNames.
1937
    // Because some Asian Document have use alias font name.
1938
    //pNewData->maMapNames = String();
1939
    if (pNewData->maMapNames.Len())
1940
	mbMapNames = true;
1870
1941
1871
    bool bKeepNewData = false;
1942
    bool bKeepNewData = false;
1872
    for( xub_StrLen nMapNameIndex = 0; nMapNameIndex != STRING_NOTFOUND; )
1943
    for( xub_StrLen nMapNameIndex = 0; nMapNameIndex != STRING_NOTFOUND; )
Lines 1883-1888 void ImplDevFontList::Add( ImplFontData* Link Here
1883
        {
1954
        {
1884
            pFoundData = new ImplDevFontListData( aSearchName );
1955
            pFoundData = new ImplDevFontListData( aSearchName );
1885
            maDevFontList[ aSearchName ] = pFoundData;
1956
            maDevFontList[ aSearchName ] = pFoundData;
1957
	    // Add by Firefly(firefly@ossii.com.tw)
1958
	    // Check and set the font group ID.
1959
	    // If not match any group, the return ID is -1.
1960
	    pFoundData->SetGroupID(ImplCheckGroupID(aSearchName, pNewData->maMapNames));
1886
        }
1961
        }
1887
1962
1888
        bKeepNewData = pFoundData->AddFontFace( pNewData );
1963
        bKeepNewData = pFoundData->AddFontFace( pNewData );
Lines 1903-1908 void ImplDevFontList::Add( ImplFontData* Link Here
1903
}
1978
}
1904
1979
1905
// -----------------------------------------------------------------------
1980
// -----------------------------------------------------------------------
1981
// Add by Firefly(firefly@ossii.com.tw)
1982
// 切割字體屬性群組字串
1983
void ImplDevFontList::AddFontGroup(const String rGroupName)
1984
{
1985
    if (rGroupName.Len())
1986
    {
1987
	xub_StrLen nTokens = rGroupName.GetTokenCount('|');
1988
	for (xub_StrLen nIndex = 0; nIndex < nTokens; nIndex++)
1989
	{
1990
	    String aGroup = rGroupName.GetToken(nIndex, '|');
1991
	    if (aGroup.Len())
1992
	    {
1993
		ImplGetEnglishSearchFontName(aGroup);
1994
		maGroupFontList.push_back(aGroup);
1995
	    }
1996
	}
1997
    }
1998
}
1999
2000
// Add by Firefly(firefly@ossii.com.tw)
2001
// 檢查並傳回字型名稱所屬 ID
2002
int ImplDevFontList::ImplCheckGroupID(const String& rName, const String& rAliasName) const
2003
{
2004
    String aFullNames = rName;
2005
    if (rAliasName.Len())
2006
    {
2007
	aFullNames.Append(';');
2008
	aFullNames.Append(rAliasName);
2009
    }
2010
    ImplGetEnglishSearchFontName(aFullNames);
2011
2012
    // 依序取出各個群組做比對
2013
    for (int i = 0 ; i < maGroupFontList.size(); i++)
2014
    {
2015
	String aGroupNames = maGroupFontList.at(i);
2016
	// 再分解群組成員與字型名稱做比對
2017
	String aTempName;
2018
	xub_StrLen nIndex = 0;
2019
	do
2020
	{
2021
	    aTempName = GetNextFontToken(aGroupNames, nIndex); // 群組成員名稱
2022
	    if (aTempName.Len() &&
2023
		 aFullNames.Search(aTempName) != STRING_NOTFOUND)
2024
	    {
2025
#if defined(HDU_DEBUG)
2026
		ByteString aName(aFullNames, RTL_TEXTENCODING_UTF8);
2027
		ByteString aGname(aTempName, RTL_TEXTENCODING_UTF8);
2028
		printf("ID=%2d, Check Name=%s, Match Group=%s\n", i, aName.GetBuffer(), aGname.GetBuffer());
2029
#endif
2030
		return i;
2031
	    }
2032
	}
2033
	while (nIndex != STRING_NOTFOUND);
2034
    }
2035
    return -1;
2036
}
2037
2038
bool ImplDevFontList::SetFallbackByGroupID(int nGroupID)
2039
{
2040
    // 字型列表是空的!?不做任何事
2041
    if (maDevFontList.empty())
2042
	return false;
2043
2044
    // 跟上次一樣的排序? 就不必再做一次
2045
    if (nGroupID == mnLastSortID)
2046
	return true;
2047
2048
    if (mpFallbackList)
2049
	delete[] mpFallbackList;
2050
2051
    // 事先取得系統自訂字型
2052
    ImplDevFontListData* pDefaultFont = FindDefaultFont();
2053
2054
    // 如果沒有字體群組或是預設字型就是指定的字體群組
2055
    // 就把預設字型放在第一位
2056
    bool bDefaultFontFirst = (nGroupID < 0 || ImplCheckGroupID(pDefaultFont->maName, pDefaultFont->maMapNames) == nGroupID);
2057
    int nSortStart = 0;
2058
2059
    mpFallbackList = new ImplDevFontListData*[maDevFontList.size()];
2060
    mnFallbackCount = 0;
2061
2062
    DevFontList::iterator it = maDevFontList.begin();
2063
    for(; it != maDevFontList.end(); ++it )
2064
    {
2065
	mpFallbackList[mnFallbackCount++] = (*it).second;
2066
	if (bDefaultFontFirst && (*it).second == pDefaultFont)
2067
	{
2068
	    ImplDevFontListData* pTmpData = mpFallbackList[0];
2069
	    mpFallbackList[mnFallbackCount - 1] = pTmpData;
2070
	    mpFallbackList[0] = (*it).second;
2071
	    nSortStart = 1;
2072
	}
2073
    }
2074
2075
    bool bHaveGroupID = false;
2076
    for(int i = nSortStart, j; i < mnFallbackCount ; ++i)
2077
    {
2078
        ImplDevFontListData* pTestFont = mpFallbackList[i];
2079
        int nTestID = pTestFont->GetGroupID();
2080
	int nTestQuality = pTestFont->GetMinQuality();
2081
	if (nTestID == nGroupID)
2082
	    bHaveGroupID = true;
2083
2084
        for(j = i ; --j >= nSortStart ;)
2085
	{
2086
            if(nTestQuality > mpFallbackList[j]->GetMinQuality())
2087
                mpFallbackList[j+1] = mpFallbackList[j];
2088
            else
2089
                break;
2090
	}
2091
        mpFallbackList[j+1] = pTestFont;
2092
    }
2093
2094
    // 需要依照字體性質排列嗎?
2095
    if (bHaveGroupID && nGroupID >= 0)
2096
    {
2097
	int nFontGroupID;
2098
	for(int i = nSortStart ; i < mnFallbackCount ; ++i)
2099
	{
2100
	    if ((nFontGroupID = mpFallbackList[i]->GetGroupID()) == nGroupID)
2101
		continue;
2102
	    for (int j = i+1 ; j < mnFallbackCount ; j++)
2103
	    {
2104
		if (mpFallbackList[j]->GetGroupID() == nGroupID)
2105
		{
2106
		    ImplDevFontListData* pTestFont = mpFallbackList[i];
2107
		    mpFallbackList[i] = mpFallbackList[j];
2108
		    mpFallbackList[j] = pTestFont;
2109
		}
2110
	    }
2111
	}
2112
    }
2113
2114
#if defined(HDU_DEBUG)
2115
    if (nGroupID >= 0)
2116
    {
2117
	ByteString aGroupName(maGroupFontList.at(nGroupID), RTL_TEXTENCODING_UTF8);
2118
	printf("SetFallbackByGroupID(%d) %s\n", nGroupID, aGroupName.GetBuffer());
2119
    }
2120
    else
2121
    {
2122
	printf("nGroupID = %d. Use Orig lists sort by Quality.\n", nGroupID);
2123
    }
2124
    for (int i=0 ; i < mnFallbackCount ; ++i)
2125
    {
2126
	ByteString aName(mpFallbackList[i]->GetFamilyName(), RTL_TEXTENCODING_UTF8);
2127
	printf("#%02d - %s(%02d)\n", i, aName.GetBuffer(), mpFallbackList[i]->GetGroupID());
2128
    }
2129
#endif
2130
2131
    mnLastSortID = nGroupID;
2132
    return true;
2133
}
2134
2135
ImplDevFontListData* ImplDevFontList::ImplFindByGroupName(const String& rName) const
2136
{
2137
    ImplDevFontListData* pFoundData = NULL;
2138
    int nGroupID = ImplCheckGroupID(rName, String());
2139
    // 取得系統字型的群組 ID
2140
    ImplDevFontListData* pDefaultData = FindDefaultFont();
2141
    int nDefaultGroupID = ImplCheckGroupID(pDefaultData->maName, pDefaultData->maMapNames);
2142
2143
    // 如果系統字型有群組,而且也跟要求的字型群組一樣的話,就傳回系統字型
2144
    if (nDefaultGroupID >= 0 && nDefaultGroupID == nGroupID)
2145
	return pDefaultData;
2146
2147
    // 有找到字體群組的話, 取出該字體群組中 Quality 最大的那個
2148
    int nQuality = 0;
2149
    if (nGroupID >= 0)
2150
    {
2151
	DevFontList::const_iterator it = maDevFontList.begin();
2152
	for(; it != maDevFontList.end(); ++it)
2153
	{
2154
	    ImplDevFontListData* pData = (*it).second;
2155
	    // 忽略不是該群組的字體
2156
	    if (pData->GetGroupID() != nGroupID)
2157
		continue;
2158
	    // 取得群組中最佳字體
2159
	    if (pData->GetMinQuality() > nQuality)
2160
	    {
2161
		pFoundData = pData;
2162
		nQuality = pData->GetMinQuality();
2163
	    }
2164
	}
2165
    }
2166
2167
    return pFoundData;
2168
}
2169
2170
// -----------------------------------------------------------------------
1906
2171
1907
// find the font from the normalized font family name
2172
// find the font from the normalized font family name
1908
ImplDevFontListData* ImplDevFontList::ImplFindBySearchName( const String& rSearchName ) const
2173
ImplDevFontListData* ImplDevFontList::ImplFindBySearchName( const String& rSearchName ) const
Lines 1914-1923 ImplDevFontListData* ImplDevFontList::Im Link Here
1914
#endif
2179
#endif
1915
2180
1916
    DevFontList::const_iterator it = maDevFontList.find( rSearchName );
2181
    DevFontList::const_iterator it = maDevFontList.find( rSearchName );
1917
    if( it == maDevFontList.end() )
2182
    // Modify By Firefly(firefly@ossii.com.tw)
1918
        return NULL;
2183
    ImplDevFontListData* pFoundData = NULL;
1919
2184
    if( it != maDevFontList.end() )
1920
    ImplDevFontListData* pFoundData = (*it).second;
2185
	pFoundData = (*it).second;
2186
    // because CJK fonts maybe have alias name
2187
    if (mbMapNames && !pFoundData)
2188
	pFoundData = ImplFindByAliasName(rSearchName, String());
1921
    return pFoundData;
2189
    return pFoundData;
1922
}
2190
}
1923
2191
Lines 1936-1953 ImplDevFontListData* ImplDevFontList::Im Link Here
1936
    // use the font's alias names to find the font
2204
    // use the font's alias names to find the font
1937
    // TODO: get rid of linear search
2205
    // TODO: get rid of linear search
1938
    DevFontList::const_iterator it = maDevFontList.begin();
2206
    DevFontList::const_iterator it = maDevFontList.begin();
1939
    while( it != maDevFontList.end() )
2207
    // Modify by Firefly(firefly@firefly.idv.tw)
2208
    // BUG! endless loop.
2209
    for( ; it != maDevFontList.end() ; ++it)
1940
    {
2210
    {
1941
        ImplDevFontListData* pData = (*it).second;
2211
        ImplDevFontListData* pData = (*it).second;
1942
        if( !pData->maMapNames.Len() )
2212
        if( !pData->maMapNames.Len() )
1943
            continue;
2213
            continue;
1944
2214
1945
        // if one alias name matches we found a matching font
2215
        // if one alias name matches we found a matching font
2216
	String aMapNames = pData->maMapNames;
1946
        String aTempName;
2217
        String aTempName;
1947
        xub_StrLen nIndex = 0;
2218
        xub_StrLen nIndex = 0;
1948
        do
2219
        do
1949
        {
2220
        {
1950
           aTempName = GetNextFontToken( pData->maMapNames, nIndex );
2221
	   ImplGetEnglishSearchFontName(aMapNames);
2222
           aTempName = GetNextFontToken(aMapNames, nIndex);
1951
           // Test, if the Font name match with one of the mapping names
2223
           // Test, if the Font name match with one of the mapping names
1952
           if ( (aTempName == rSearchName) || (aTempName == rShortName) )
2224
           if ( (aTempName == rSearchName) || (aTempName == rShortName) )
1953
              return pData;
2225
              return pData;
Lines 2035-2040 void ImplDevFontList::InitMatchData() co Link Here
2035
2307
2036
// -----------------------------------------------------------------------
2308
// -----------------------------------------------------------------------
2037
2309
2310
// Disable by Firefly(firefly@ossii.com.tw)
2311
// 已經不需要了
2312
#if 1
2038
ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType,
2313
ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType,
2039
    FontWeight eSearchWeight, FontWidth eSearchWidth, FontFamily eSearchFamily,
2314
    FontWeight eSearchWeight, FontWidth eSearchWidth, FontFamily eSearchFamily,
2040
    FontItalic eSearchItalic, const String& rSearchFamilyName ) const
2315
    FontItalic eSearchItalic, const String& rSearchFamilyName ) const
Lines 2393-2398 ImplDevFontListData* ImplDevFontList::Im Link Here
2393
2668
2394
    return pFoundData;
2669
    return pFoundData;
2395
}
2670
}
2671
#endif
2396
2672
2397
// -----------------------------------------------------------------------
2673
// -----------------------------------------------------------------------
2398
2674
Lines 2401-2406 ImplDevFontListData* ImplDevFontList::Fi Link Here
2401
    // try to find one of the default fonts of the
2677
    // try to find one of the default fonts of the
2402
    // UNICODE, SANSSERIF, SERIF or FIXED default font lists
2678
    // UNICODE, SANSSERIF, SERIF or FIXED default font lists
2403
    const DefaultFontConfigItem& rDefaults = *DefaultFontConfigItem::get();
2679
    const DefaultFontConfigItem& rDefaults = *DefaultFontConfigItem::get();
2680
// Add by Firefly(firefly@ossii.com.tw)
2681
// 依據國家地區別,取出預設字型才對,否則都以英文為主,取出的字型就不對
2682
#if 1
2683
    com::sun::star::lang::Locale aLocale = Application::GetSettings().GetLocale();
2684
    OUString aLanguage = aLocale.Language.toAsciiLowerCase();
2685
    OUString aCountry  = aLocale.Country.toAsciiLowerCase();
2686
    USHORT nType[4];
2687
    if (aLanguage.equalsAscii("zh") ||
2688
	aLanguage.equalsAscii("ja") ||
2689
	aLanguage.equalsAscii("ko"))
2690
    {
2691
	nType[0] = DEFAULTFONT_CJK_TEXT;
2692
	nType[1] = DEFAULTFONT_CJK_DISPLAY;
2693
	nType[2] = DEFAULTFONT_UI_SANS;
2694
	nType[3] = DEFAULTFONT_UI_FIXED;
2695
    }
2696
    else
2697
    {
2698
	nType[0] = DEFAULTFONT_SANS_UNICODE;
2699
	nType[1] = DEFAULTFONT_SANS;
2700
	nType[2] = DEFAULTFONT_SERIF;
2701
	nType[3] = DEFAULTFONT_FIXED;
2702
    }
2703
2704
    String aFontname;
2705
    ImplDevFontListData* pFoundData = NULL;
2706
2707
    for (int i = 0 ; i < sizeof(nType) ; i++)
2708
    {
2709
	aFontname = rDefaults.getDefaultFont(aLocale, nType[i]);
2710
	pFoundData = ImplFindByTokenNames(aFontname);
2711
	if (pFoundData)
2712
	    return pFoundData;
2713
    }
2714
#else
2404
    com::sun::star::lang::Locale aLocale( OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), OUString(), OUString() );
2715
    com::sun::star::lang::Locale aLocale( OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), OUString(), OUString() );
2405
    String aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_SANS_UNICODE );
2716
    String aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_SANS_UNICODE );
2406
    ImplDevFontListData* pFoundData = ImplFindByTokenNames( aFontname );
2717
    ImplDevFontListData* pFoundData = ImplFindByTokenNames( aFontname );
Lines 2421-2426 ImplDevFontListData* ImplDevFontList::Fi Link Here
2421
    pFoundData = ImplFindByTokenNames( aFontname );
2732
    pFoundData = ImplFindByTokenNames( aFontname );
2422
    if( pFoundData )
2733
    if( pFoundData )
2423
        return pFoundData;
2734
        return pFoundData;
2735
#endif
2424
2736
2425
    // now try to find a reasonable non-symbol font
2737
    // now try to find a reasonable non-symbol font
2426
2738
Lines 2767-2772 ImplDevFontListData* ImplDevFontList::Im Link Here
2767
        aSearchName = rFSD.maTargetName;
3079
        aSearchName = rFSD.maTargetName;
2768
        ImplGetEnglishSearchFontName( aSearchName );
3080
        ImplGetEnglishSearchFontName( aSearchName );
2769
        ImplFontSubstitute( aSearchName, nSubstFlags, pDevSpecific );
3081
        ImplFontSubstitute( aSearchName, nSubstFlags, pDevSpecific );
3082
// Disable by Firefly(firefly@ossii.com.tw)
3083
#if 0
2770
        // #114999# special emboldening for Ricoh fonts
3084
        // #114999# special emboldening for Ricoh fonts
2771
        // workaround until all platforms support artificial styles
3085
        // workaround until all platforms support artificial styles
2772
        // TODO: smarter check for special cases
3086
        // TODO: smarter check for special cases
Lines 2790-2795 ImplDevFontListData* ImplDevFontList::Im Link Here
2790
            else // restore font weight
3104
            else // restore font weight
2791
                rFSD.meWeight = eWeight;
3105
                rFSD.meWeight = eWeight;
2792
        }
3106
        }
3107
#endif
2793
        ImplDevFontListData* pFoundData = ImplFindBySearchName( aSearchName );
3108
        ImplDevFontListData* pFoundData = ImplFindBySearchName( aSearchName );
2794
        if( pFoundData )
3109
        if( pFoundData )
2795
            return pFoundData;
3110
            return pFoundData;
Lines 2847-2852 ImplDevFontListData* ImplDevFontList::Im Link Here
2847
       ImplDevFontListData* pFoundData = ImplFindBySearchName( aSearchShortName );
3162
       ImplDevFontListData* pFoundData = ImplFindBySearchName( aSearchShortName );
2848
       if( pFoundData )
3163
       if( pFoundData )
2849
       {
3164
       {
3165
// Disable by Firefly(firefly@ossii.com.tw)
3166
#if 0
2850
#ifdef UNX
3167
#ifdef UNX
2851
            /* #96738# don't use mincho as an replacement for "MS Mincho" on X11: Mincho is
3168
            /* #96738# don't use mincho as an replacement for "MS Mincho" on X11: Mincho is
2852
            a korean bitmap font that is not suitable here. Use the font replacement table,
3169
            a korean bitmap font that is not suitable here. Use the font replacement table,
Lines 2857-2862 ImplDevFontListData* ImplDevFontList::Im Link Here
2857
            if ((aSearchName != aMS_Mincho) && (aSearchName != aMS_Gothic))
3174
            if ((aSearchName != aMS_Mincho) && (aSearchName != aMS_Gothic))
2858
                // TODO: add heuristic to only throw out the fake ms* fonts
3175
                // TODO: add heuristic to only throw out the fake ms* fonts
2859
#endif
3176
#endif
3177
#endif
2860
            {
3178
            {
2861
                return pFoundData;
3179
                return pFoundData;
2862
            }
3180
            }
Lines 2895-2900 ImplDevFontListData* ImplDevFontList::Im Link Here
2895
            return pFoundData;
3213
            return pFoundData;
2896
    }
3214
    }
2897
3215
3216
// Disable by Firefly(firefly@ossii.com.tw)
3217
#if 0
2898
    // now try the other font name tokens
3218
    // now try the other font name tokens
2899
    while( nTokenPos != STRING_NOTFOUND )
3219
    while( nTokenPos != STRING_NOTFOUND )
2900
    {
3220
    {
Lines 2950-2956 ImplDevFontListData* ImplDevFontList::Im Link Here
2950
        if( pFoundData )
3270
        if( pFoundData )
2951
            return pFoundData;
3271
            return pFoundData;
2952
    }
3272
    }
3273
#endif
2953
3274
3275
    // Add by Firefly(firefly@ossii.com.tw)
3276
    // 看看有無同性質的字體
3277
    if (maGroupFontList.size())
3278
    {
3279
	ImplDevFontListData* pGroupData = ImplFindByGroupName(rFSD.maName);
3280
	if (pGroupData)
3281
	    return pGroupData;
3282
    }
3283
#if 1
3284
    return FindDefaultFont();
3285
#else
2954
    // if still needed use the font request's attributes to find a good match
3286
    // if still needed use the font request's attributes to find a good match
2955
    switch( rFSD.meLanguage )
3287
    switch( rFSD.meLanguage )
2956
    {
3288
    {
Lines 3007-3016 ImplDevFontListData* ImplDevFontList::Im Link Here
3007
    }
3339
    }
3008
3340
3009
    return pFoundData;
3341
    return pFoundData;
3342
#endif
3010
}
3343
}
3011
3344
3012
// -----------------------------------------------------------------------
3345
// -----------------------------------------------------------------------
3013
3346
3347
#if 0
3014
ImplFontEntry* ImplFontCache::GetFallback( ImplDevFontList* pFontList,
3348
ImplFontEntry* ImplFontCache::GetFallback( ImplDevFontList* pFontList,
3015
    const Font& rOrigFont, const Size& rSize, int nFallbackLevel )
3349
    const Font& rOrigFont, const Size& rSize, int nFallbackLevel )
3016
{
3350
{
Lines 3132-3137 ImplFontEntry* ImplFontCache::GetFallbac Link Here
3132
3466
3133
    return pFallbackFont;
3467
    return pFallbackFont;
3134
}
3468
}
3469
#endif
3135
3470
3136
// -----------------------------------------------------------------------
3471
// -----------------------------------------------------------------------
3137
3472
Lines 6151-6156 SalLayout* OutputDevice::ImplGlyphFallba Link Here
6151
    if( mpOutDevData && mpOutDevData->mpFirstFontSubstEntry )
6486
    if( mpOutDevData && mpOutDevData->mpFirstFontSubstEntry )
6152
        nDevSpecificFallback = 1;
6487
        nDevSpecificFallback = 1;
6153
6488
6489
    // Add by Firefly(firefly@firefly.idv.tw)
6490
    // 取得這個字體的群組 ID 
6491
    int nGroupID = mpFontList->ImplCheckGroupID(maFont.GetName(), String());
6492
    bool bSuccess = mpFontList->SetFallbackByGroupID(nGroupID);
6493
    ByteString aSelectName(maFont.GetName(), RTL_TEXTENCODING_UTF8);
6494
6495
    int nFallbackLevel = 1 - nDevSpecificFallback;
6496
    int nIndex = 0;
6497
    // try if fallback fonts support the missing unicodes
6498
    while (nIndex < mpFontList->GetFallbackCount())
6499
    {
6500
	Font aFallbackFont = maFont;
6501
	if (nFallbackLevel > 0)
6502
	{
6503
	    ImplDevFontListData* pFallbackData = mpFontList->GetFallback(nIndex);
6504
	    if (!pFallbackData)
6505
		break;
6506
	    aFallbackFont.SetName(pFallbackData->GetSearchName());
6507
	}
6508
6509
	ImplFontEntry* pFallbackFont = mpFontCache->Get(mpFontList, aFallbackFont, aFontSize, NULL );
6510
6511
	if( pFallbackFont && !pFallbackFont->mbInit )
6512
	{
6513
	    pFallbackFont->maMetric.maName      =
6514
	    pFallbackFont->maMetric.maStyleName = String();
6515
	}
6516
        aFontSelData.mpFontEntry = pFallbackFont;
6517
        aFontSelData.mpFontData = pFallbackFont->maFontSelData.mpFontData;
6518
        if(mpFontEntry)
6519
        {
6520
            if( mpFontEntry->maFontSelData.mpFontData == aFontSelData.mpFontData )
6521
            {
6522
                mpFontCache->Release( pFallbackFont );
6523
		nIndex ++;
6524
		continue;
6525
            }
6526
        }
6527
6528
        pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel );
6529
6530
        // create and add glyph fallback layout to multilayout
6531
        rLayoutArgs.ResetPos();
6532
        SalLayout* pFallback = mpGraphics->GetTextLayout( rLayoutArgs, nFallbackLevel );
6533
6534
        if( pFallback )
6535
        {
6536
            if( pFallback->LayoutText( rLayoutArgs ) )
6537
            {
6538
                if( !pMultiSalLayout )
6539
                    pMultiSalLayout = new MultiSalLayout( *pSalLayout );
6540
                pMultiSalLayout->AddFallback( *pFallback,
6541
                    rLayoutArgs.maRuns, aFontSelData.mpFontData );
6542
            }
6543
            else
6544
                pFallback->Release();
6545
        }
6546
6547
        mpFontCache->Release( pFallbackFont );
6548
6549
        if( !rLayoutArgs.PrepareFallback() )
6550
            break;
6551
6552
        if (nFallbackLevel > 0)
6553
	    nIndex ++;
6554
6555
	nFallbackLevel ++;
6556
	// 到此為止,沒有任何符合的字型,那就清除 Fallback list
6557
	// 重頭再來
6558
	if (nFallbackLevel >= MAX_FALLBACK)
6559
	{
6560
	    nFallbackLevel = 1;
6561
6562
	    if (pMultiSalLayout)
6563
	    {
6564
		for( int i = 1; i < pMultiSalLayout->mnLevel; ++i )
6565
		    pMultiSalLayout->mpLayouts[i]->Release();
6566
		pMultiSalLayout->mnLevel = 1;
6567
	    }
6568
	}
6569
    }
6570
6571
#if 0
6154
    // try if fallback fonts support the missing unicodes
6572
    // try if fallback fonts support the missing unicodes
6155
    for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel )
6573
    for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel )
6156
    {
6574
    {
Lines 6207-6212 SalLayout* OutputDevice::ImplGlyphFallba Link Here
6207
        if( !rLayoutArgs.PrepareFallback() )
6625
        if( !rLayoutArgs.PrepareFallback() )
6208
            break;
6626
            break;
6209
    }
6627
    }
6628
#endif
6210
6629
6211
    if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
6630
    if( pMultiSalLayout && pMultiSalLayout->LayoutText( rLayoutArgs ) )
6212
        pSalLayout = pMultiSalLayout;
6631
        pSalLayout = pMultiSalLayout;

Return to issue 63637