LCOV - code coverage report
Current view: top level - hwpfilter/source - fontmap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 8 75.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : #ifdef SOLARIS
      22             : #include <strings.h>
      23             : #else
      24             : #include <string.h>
      25             : #endif
      26             : 
      27             : #include <fontmap.hxx>
      28             : 
      29             : // #i42367# prevent MS compiler from using system locale for parsing
      30             : #ifdef _MSC_VER
      31             : #pragma setlocale("C")
      32             : #endif
      33             : 
      34             : 
      35             : struct FontEntry
      36             : {
      37             :     const char *familyname;
      38             :     int key;
      39             :      double ratio;
      40             : };
      41             : /**
      42             :  * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9.
      43             :  */
      44             : const struct FontEntry FontMapTab[] =
      45             : {
      46             :     {"\xb8\xed\xc1\xb6",0, 0.97},
      47             :     {"\xb0\xed\xb5\xf1",1, 0.97},
      48             :     {"\xbb\xf9\xb9\xb0",1, 0.97},
      49             :     {"\xc7\xca\xb1\xe2",0, 0.97},
      50             :     {"\xbd\xc3\xbd\xba\xc5\xdb",1, 0.84},
      51             :     {"\xbd\xc3\xbd\xba\xc5\xdb \xbe\xe0\xc0\xda",1, 0.84},
      52             :     {"\xbd\xc3\xbd\xba\xc5\xdb \xb0\xa3\xc0\xda",1, 0.84},
      53             :     {"HY\xb5\xd5\xb1\xd9 \xb0\xed\xb5\xf1",2, 0.97},
      54             :     {"\xbf\xbe\xc7\xd1\xb1\xdb",0, 0.97},
      55             :     {"\xb0\xa1\xb4\xc2\xb0\xf8\xc7\xd1",0, 0.72},
      56             :     {"\xc1\xdf\xb0\xa3\xb0\xf8\xc7\xd1",0, 0.72},
      57             :     {"\xb1\xbd\xc0\xba\xb0\xf8\xc7\xd1",0, 0.72},
      58             :     {"\xb0\xa1\xb4\xc2\xc7\xd1",0, 0.72},
      59             :     {"\xc1\xdf\xb0\xa3\xc7\xd1",0, 0.72},
      60             :     {"\xb1\xbd\xc0\xba\xc7\xd1",0, 0.72},
      61             :     {"\xc8\xde\xb8\xd5\xb8\xed\xc1\xb6",0, 0.97},
      62             :     {"\xc8\xde\xb8\xd5\xb0\xed\xb5\xf1",1, 0.97},
      63             :     {"\xb0\xa1\xb4\xc2\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.55},
      64             :     {"\xc1\xdf\xb0\xa3\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.637},
      65             :     {"\xb1\xbd\xc0\xba\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.63},
      66             :     {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xbb\xf9\xc3\xbc",0, 0.666},
      67             :     {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xbb\xf9\xc3\xbc",0, 0.685},
      68             :     {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xbb\xf9\xc3\xbc",0, 0.727},
      69             :     {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xc6\xd4\xc3\xbc",0, 0.666},
      70             :     {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xc6\xd4\xc3\xbc",0, 0.685},
      71             :     {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xc6\xd4\xc3\xbc",0, 0.727},
      72             :     {"\xc8\xde\xb8\xd5\xbf\xbe\xc3\xbc",3, 0.97},
      73             :     {"\xc7\xd1\xbe\xe7\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
      74             :     {"\xc7\xd1\xbe\xe7\xb0\xdf\xb8\xed\xc1\xb6",1, 0.97},
      75             :     {"\xc7\xd1\xbe\xe7\xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
      76             :     {"\xc7\xd1\xbe\xe7\xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
      77             :     {"\xc7\xd1\xbe\xe7\xb1\xd7\xb7\xa1\xc7\xc8",0, 0.97},
      78             :     {"\xc7\xd1\xbe\xe7\xb1\xc3\xbc\xad",3, 0.97},
      79             :     {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1",0, 0.97},
      80             :     {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1\xc1\xa6\xb8\xf1",1, 0.97},
      81             :     {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2",1, 0.97},
      82             :     {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2\xc1\xa6\xb8\xf1",0, 0.97},
      83             :     {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2",0, 0.97},
      84             :     {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2\xc8\xea\xb8\xb2",0, 0.97},
      85             :     {"\xc6\xe6\xc8\xea\xb8\xb2",0, 0.97},
      86             :     {"\xba\xb9\xbc\xfe\xbe\xc6",0, 0.827},
      87             :     {"\xbf\xc1\xbc\xf6\xbc\xf6",0, 0.97},
      88             :     {"\xbf\xc0\xc0\xcc",0, 0.97},
      89             :     {"\xb0\xa1\xc1\xf6",0, 0.97},
      90             :     {"\xb0\xad\xb3\xb6\xc4\xe1",2, 0.97},
      91             :     {"\xb5\xfe\xb1\xe2",3, 0.97},
      92             :     {"\xc5\xb8\xc0\xcc\xc7\xc1",0, 0.987},
      93             :     {"\xc5\xc2 \xb3\xaa\xb9\xab",1, 0.97},
      94             :     {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
      95             :     {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
      96             :     {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
      97             :     {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
      98             :     {"\xbe\xe7\xc0\xe7 \xb4\xd9\xbf\xee\xb8\xed\xc1\xb6M",0, 0.97},
      99             :     {"\xbe\xe7\xc0\xe7 \xba\xbb\xb8\xf1\xb0\xa2M",0, 0.97},
     100             :     {"\xbe\xe7\xc0\xe7 \xbc\xd2\xbd\xbd",1, 0.97},
     101             :     {"\xbe\xe7\xc0\xe7 \xb8\xc5\xc8\xad",1, 0.987},
     102             :     {"\xbe\xe7\xc0\xe7 \xc6\xb0\xc6\xb0",0, 0.97},
     103             :     {"\xbe\xe7\xc0\xe7 \xc2\xfc\xbd\xa1",1, 0.97},
     104             :     {"\xbe\xe7\xc0\xe7 \xb5\xd1\xb1\xe2",0, 0.97},
     105             :     {"\xbe\xe7\xc0\xe7 \xbb\xfe\xb3\xda",1, 0.97},
     106             :     {"\xbe\xe7\xc0\xe7 \xbf\xcd\xb4\xe7",1, 0.97},
     107             :     {"\xbd\xc5\xb8\xed \xbc\xbc\xb8\xed\xc1\xb6",0, 0.97},
     108             :     {"\xbd\xc5\xb8\xed \xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
     109             :     {"\xbd\xc5\xb8\xed \xbd\xc5\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
     110             :     {"\xbd\xc5\xb8\xed \xc1\xdf\xb8\xed\xc1\xb6",0, 0.97},
     111             :     {"\xbd\xc5\xb8\xed \xc5\xc2\xb8\xed\xc1\xb6",0, 0.97},
     112             :     {"\xbd\xc5\xb8\xed \xb0\xdf\xb8\xed\xc1\xb6",0, 0.97},
     113             :     {"\xbd\xc5\xb8\xed \xbd\xc5\xb9\xae\xb8\xed\xc1\xb6",0, 0.97},
     114             :     {"\xbd\xc5\xb8\xed \xbc\xf8\xb8\xed\xc1\xb6",0, 0.97},
     115             :     {"\xbd\xc5\xb8\xed \xbc\xbc\xb0\xed\xb5\xf1",1, 0.97},
     116             :     {"\xbd\xc5\xb8\xed \xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
     117             :     {"\xbd\xc5\xb8\xed \xc5\xc2\xb0\xed\xb5\xf1",1, 0.97},
     118             :     {"\xbd\xc5\xb8\xed \xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
     119             :     {"\xbd\xc5\xb8\xed \xbc\xbc\xb3\xaa\xb7\xe7",2, 0.97},
     120             :     {"\xbd\xc5\xb8\xed \xb5\xf0\xb3\xaa\xb7\xe7",2, 0.97},
     121             :     {"\xbd\xc5\xb8\xed \xbd\xc5\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
     122             :     {"\xbd\xc5\xb8\xed \xc5\xc2\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
     123             :     {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97}
     124             : };
     125             : 
     126             : #ifndef WIN32
     127             : #if defined(LINUX)
     128             : const char* RepFontTab[] =
     129             : {
     130             :     "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1",                                     /* 0 */
     131             :     "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2",                                      /* 1 */
     132             :     "\xb9\xe9\xb9\xac \xb1\xbc\xb8\xb2",                                      /* 2 */
     133             :     "\xb9\xe9\xb9\xac \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce"                                      /* 3 */
     134             : };
     135             : #else
     136             : const char* RepFontTab[] =
     137             : {
     138             :     "Batang",                                     /* 0 */
     139             :     "Dotum",                                      /* 1 */
     140             :     "Gulim",                                      /* 2 */
     141             :     "Gungso"                                      /* 3 */
     142             : };
     143             : #endif
     144             : #else
     145             : const char* RepFontTab[] =
     146             : {
     147             :     "\xb9\xd9\xc5\xc1",                                       /* 0 */
     148             :     "\xb5\xb8\xbf\xf2",                                       /* 1 */
     149             :     "\xb1\xbc\xb8\xb2",                                       /* 2 */
     150             :     "\xb1\xc3\xbc\xad"                                        /* 3 */
     151             : };
     152             : #endif
     153             : 
     154          14 : int getRepFamilyName(const char* orig, char *buf, double &ratio)
     155             : {
     156             :     int i;
     157          14 :     int size = sizeof(FontMapTab)/sizeof(FontEntry);
     158        1106 :     for( i = 0 ; i < size ; i++)
     159             :     {
     160        1092 :         if( !strcmp(orig, FontMapTab[i].familyname) ){
     161           0 :                 ratio = FontMapTab[i].ratio;
     162           0 :             return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) );
     163             :           }
     164             :     }
     165          14 :      ratio = FontMapTab[0].ratio;
     166          14 :     return strlen( strcpy(buf, RepFontTab[0] ) );
     167             : }
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11