bool DisassemblyWindow::UpdateStyle(int Pos, int Inserted, int Deleted, int Restyled, const char *pszDeleted) { int Start, End; char *pText; //If this is just a selection change, then unselect the style buffer if(Inserted == 0 && Deleted == 0) { pTextDisplay->pStyleBuffer->unselect(); return true; } //Select the area that was just updated to avoid unnecessary callbacks pTextDisplay->pStyleBuffer->select(Pos, Pos + Inserted - Deleted); //Re-parse the changed region; we do this by parsing from the //beginning of the line of the changed region to the end of //the line of the changed region. Start = pTextDisplay->pTextBuffer->line_start(Pos); End = pTextDisplay->pTextBuffer->line_end(Pos + Inserted); string sText(pText = pTextDisplay->pTextBuffer->text_range(Start, End)); delete [] pText; string sStyle;//(pText = pTextDisplay->pStyleBuffer->text_range(Start, End)); //delete [] pText; ParseStyle(sText, sStyle); pTextDisplay->pStyleBuffer->append(sStyle.c_str()); pTextDisplay->redisplay_range(Start, End); return true; }
static void ParseStyles(FXSettings*reg, const char*section, StyleDef *style) { int i; for (i=0; style[i].key; i++) { ParseStyle(reg,section,&style[i]); } }
/** * Parses one ObsZone line from the See You task file * @param turnpoint_infos Updated with the OZ info * @param params Input array of parameters preparsed from See You task file * @param n_params Number parameters in the line * @return OZ index from CU (0 to n-1) or -1 if no OZ found */ static int ParseOZs(SeeYouTurnpointInformation turnpoint_infos[], const TCHAR *params[], unsigned n_params) { // Read OZ index TCHAR* end; const int oz_index = _tcstol(params[0] + 8, &end, 10); if (params[0] + 8 == end || oz_index >= 30) return -1; turnpoint_infos[oz_index].valid = true; // Iterate through available OZ options for (unsigned i = 1; i < n_params; i++) { const TCHAR *pair = params[i]; SeeYouTurnpointInformation &tp_info = turnpoint_infos[oz_index]; if (_tcsncmp(pair, _T("style"), 5) == 0) { if (_tcslen(pair) > 6) tp_info.style = ParseStyle(pair + 6); } else if (_tcsncmp(pair, _T("R1="), 3) == 0) { if (_tcslen(pair) > 3) tp_info.radius1 = ParseRadius(pair + 3); } else if (_tcsncmp(pair, _T("A1="), 3) == 0) { if (_tcslen(pair) > 3) tp_info.angle1 = ParseAngle(pair + 3); } else if (_tcsncmp(pair, _T("R2="), 3) == 0) { if (_tcslen(pair) > 3) tp_info.radius2 = ParseRadius(pair + 3); } else if (_tcsncmp(pair, _T("A2="), 3) == 0) { if (_tcslen(pair) > 3) tp_info.angle2 = ParseAngle(pair + 3); } else if (_tcsncmp(pair, _T("A12="), 4) == 0) { if (_tcslen(pair) > 3) tp_info.angle12 = ParseAngle(pair + 4); } else if (_tcsncmp(pair, _T("max_altitude="), 7) == 0) { if (_tcslen(pair) > 7) tp_info.max_altitude = ParseMaxAlt(pair + 7); } else if (_tcsncmp(pair, _T("is_line"), 4) == 0) { if (_tcslen(pair) > 5 && pair[5] == _T('1')) tp_info.is_line = true; } else if (_tcsncmp(pair, _T("reduce"), 6) == 0) { if (_tcslen(pair) > 7 && pair[7] == _T('1')) tp_info.reduce = true; } } return oz_index; }
///////////////////////////////////////////////////////////////////////////// // 分析单个行 // 语法规则: // 1.可以有若干个设置项,用";"隔开 // 2.添加列: ADDCOLUMN name,width,format // 3.删除列: DELCOLUMN nCol|all // 4.删除行: DELITEM nItem|all // 5.设置分割符: SEPARATOR=??? // 6.设置所有行的颜色: SETROWCOLORS cText cTextBk // 7.设置颜色表的某个颜色: SETCOLORTABLE index color // 8.修改控件风格: MODIFYSTYLE ADD|REMOVE style // 9.从注册表读取列信息: READPROFILE Section, Entry // 10.向注册表写入列信息: WRITEPROFILE Section, Entry // 11.设置窗口关闭时执行的脚本: SETCLOSESCRIPT script // 12.设置字体: SETFONT font size ///////////////////////////////////////////////////////////////////////////// void CTreeOutCtrl::ParseALine(CString strLine) { CString strSet = strLine; strSet.MakeUpper(); int pos; if((pos = strSet.Find("ADDCOLUMN ")) == 0) // 添加列 { CString strColName; CString strFormat = _T("LEFT"); strSet = strLine.Right(strLine.GetLength()-10); int nPos = strSet.Find(","); strColName = strSet.Left(nPos); strSet = strSet.Right(strSet.GetLength()-nPos-1); // 解析列宽度 nPos = strSet.Find(","); if(nPos != -1) { strFormat = strSet.Right(strSet.GetLength()-nPos-1); strFormat.MakeUpper(); strSet = strSet.Left(nPos); } int nWidth = atoi(strSet); RVSUBITEM rvs; rvs.nFormat = RVCF_TEXT|RVCF_EX_TOOLTIP|RVCF_EX_PERSISTENT; if(strFormat == _T("CENTER")) { rvs.nFormat |= RVCF_CENTER; } else if(strFormat == _T("RIGHT")) { rvs.nFormat |= RVCF_RIGHT; } rvs.lpszText = strColName.GetBuffer(strColName.GetLength()+1); rvs.iWidth = nWidth; int nSubItem = GetActiveSubItemCount(); DefineSubItem(nSubItem, &rvs, TRUE); ActivateSubItem(nSubItem, nSubItem); strColName.ReleaseBuffer(); } else if((pos = strSet.Find("DELCOLUMN ")) == 0) // 删除列 { strSet = strSet.Right(strSet.GetLength()-10); if(strSet == _T("ALL")) { UndefineAllSubItems(); m_asItemScript.RemoveAll(); } else { int nCol = atoi(strSet); UndefineSubItem(nCol); if(GetActiveSubItemCount() == 0) { m_asItemScript.RemoveAll(); } } } else if((pos = strSet.Find("DELITEM ")) == 0) // 删除行 { strSet = strSet.Right(strSet.GetLength()-8); if(strSet == _T("ALL")) { DeleteAllItems(); m_asItemScript.RemoveAll(); } else { int nItem = atoi(strSet); HTREEITEM hItem = GetItemHandle(nItem); DeleteItem(hItem); if(GetItemCount() == 0) { m_asItemScript.RemoveAll(); } } } else if((pos = strSet.Find("SEPARATOR=")) == 0) // 设置分割符 { m_strSeparator = strLine.Right(strLine.GetLength()-10); } else if((pos = strSet.Find("SETROWCOLORS ")) == 0) // 设置所有行颜色 { strSet = strSet.Right(strSet.GetLength()-13); CString strBkColor = _T(""); int nPos = strSet.Find(" "); if(nPos != -1) { strBkColor = strSet.Right(strSet.GetLength()-nPos-1); strSet = strSet.Left(nPos); } COLORREF cText = RGB(0,0,0); COLORREF cTextBk = RGB(255,255,255); int nPos1; if((nPos1 = strSet.Find("RGB(")) == 0) { strSet = strSet.Right(strSet.GetLength()-pos-4); strSet.Delete(strSet.GetLength()-1, 1); nPos1 = strSet.Find(","); CString strTmp = strSet.Left(nPos1); int nr = atoi(strTmp); strSet = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); nPos1 = strSet.Find(","); strTmp = strSet.Left(nPos1); int ng = atoi(strTmp); strTmp = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); int nb = atoi(strTmp); cText = RGB(nr, ng, nb); } strSet = strBkColor; if((nPos1 = strSet.Find("RGB(")) == 0) { strSet = strSet.Right(strSet.GetLength()-pos-4); strSet.Delete(strSet.GetLength()-1, 1); nPos1 = strSet.Find(","); CString strTmp = strSet.Left(nPos1); int nr = atoi(strTmp); strSet = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); nPos1 = strSet.Find(","); strTmp = strSet.Left(nPos1); int ng = atoi(strTmp); strTmp = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); int nb = atoi(strTmp); cTextBk = RGB(nr, ng, nb); } SetRowColors(cText, cTextBk); } else if((pos = strSet.Find("SETCOLORTABLE ")) == 0) // 设置颜色表的某个颜色 { strSet = strSet.Right(strSet.GetLength()-14); int nIndex = 0; int nPos = strSet.Find(" "); if(nPos != -1) { CString strIndex = strSet.Left(nPos); nIndex = atoi(strIndex); if(nIndex<0 || nIndex>9) return; strSet.Delete(0, nPos+1); } if(strSet.Find("RGB(") == 0) { strSet = strSet.Right(strSet.GetLength()-pos-4); strSet.Delete(strSet.GetLength()-1, 1); int nPos1 = strSet.Find(","); CString strTmp = strSet.Left(nPos1); int nr = atoi(strTmp); strSet = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); nPos1 = strSet.Find(","); strTmp = strSet.Left(nPos1); int ng = atoi(strTmp); strTmp = strSet.Mid(nPos1 + 1, strSet.GetLength() - nPos1 -1); int nb = atoi(strTmp); COLORREF cColor = RGB(nr, ng, nb); SetColor(nIndex, cColor); } } else if((pos = strSet.Find("MODIFYSTYLE ")) == 0) // 修改控件风格 { strSet = strSet.Right(strSet.GetLength()-12); BOOL bAdd = TRUE; if(strSet.Find("REMOVE(") == 0) { bAdd = FALSE; strSet.Delete(0, 7); } else { strSet.Delete(0, 4); } int nPos = strSet.Find(")"); if(nPos != -1) { strSet = strSet.Left(nPos); } int nStyle = 0; while((nPos=strSet.Find("|")) != -1) { CString strStyle = strSet.Left(nPos); nStyle |= ParseStyle(strStyle); strSet.Delete(0, nPos+1); } nStyle |= ParseStyle(strSet); ModifyStyle(bAdd ? 0 : nStyle, bAdd ? nStyle : 0); } else if(strSet.Find("READPROFILE ") == 0) // 从注册表读取列信息 { strLine = strLine.Right(strLine.GetLength()-12); int nPos = strLine.Find(","); if(nPos != -1) { CString strSection = strLine.Left(nPos); CString strEntry = strLine.Right(strLine.GetLength()-nPos-1); GetProfile(strSection, strEntry); } } else if(strSet.Find("WRITEPROFILE ") == 0) // 向注册表写入列信息 { strLine = strLine.Right(strLine.GetLength()-13); int nPos = strLine.Find(","); if(nPos != -1) { CString strSection = strLine.Left(nPos); CString strEntry = strLine.Right(strLine.GetLength()-nPos-1); WriteProfile(strSection, strEntry); } } else if(strSet.Find("SETCLOSESCRIPT ") == 0) // 设置窗口关闭时执行的脚本 { m_strScriptClose = strLine.Right(strLine.GetLength()-15); } else if(strSet.Find("SETFONT ") == 0) // 设置字体 { strLine = strLine.Right(strLine.GetLength()-8); CString strFont = strLine; int nSize = 0; int nPos = strLine.Find(","); if(nPos != -1) { strFont = strLine.Left(nPos); CString strSize = strLine.Right(strLine.GetLength()-nPos-1); nSize = atoi(strSize); } SetSelfFont(strFont, nSize); } }
bool WaypointReaderSeeYou::ParseLine(const TCHAR* line, Waypoints &waypoints) { enum { iName = 0, iLatitude = 3, iLongitude = 4, iElevation = 5, iStyle = 6, iRWDir = 7, iRWLen = 8, iFrequency = 9, iDescription = 10, }; if (first) { first = false; /* skip first line if it doesn't begin with a quotation character (usually the field order line) */ if (line[0] != _T('\"')) return true; } // If (end-of-file or comment) if (StringIsEmpty(line) || StringStartsWith(line, _T("*"))) // -> return without error condition return true; TCHAR ctemp[4096]; if (_tcslen(line) >= ARRAY_SIZE(ctemp)) /* line too long for buffer */ return false; // If task marker is reached ignore all following lines if (StringStartsWith(line, _T("-----Related Tasks-----"))) ignore_following = true; if (ignore_following) return true; // Get fields const TCHAR *params[20]; size_t n_params = ExtractParameters(line, ctemp, params, ARRAY_SIZE(params), true, _T('"')); // Check if the basic fields are provided if (iName >= n_params || iLatitude >= n_params || iLongitude >= n_params) return false; GeoPoint location; // Latitude (e.g. 5115.900N) if (!ParseAngle(params[iLatitude], location.latitude, true)) return false; // Longitude (e.g. 00715.900W) if (!ParseAngle(params[iLongitude], location.longitude, false)) return false; location.Normalize(); // ensure longitude is within -180:180 Waypoint new_waypoint = factory.Create(location); // Name (e.g. "Some Turnpoint") if (*params[iName] == _T('\0')) return false; new_waypoint.name = params[iName]; // Elevation (e.g. 458.0m) /// @todo configurable behaviour if ((iElevation >= n_params || !ParseAltitude(params[iElevation], new_waypoint.elevation)) && !factory.FallbackElevation(new_waypoint)) return false; // Style (e.g. 5) if (iStyle < n_params) ParseStyle(params[iStyle], new_waypoint.type); new_waypoint.flags.turn_point = true; // Frequency & runway direction/length (for airports and landables) // and description (e.g. "Some Description") if (new_waypoint.IsLandable()) { if (iFrequency < n_params) new_waypoint.radio_frequency = RadioFrequency::Parse(params[iFrequency]); // Runway length (e.g. 546.0m) double rwlen = -1; if (iRWLen < n_params && ParseDistance(params[iRWLen], rwlen) && rwlen > 0) new_waypoint.runway.SetLength(uround(rwlen)); if (iRWDir < n_params && *params[iRWDir]) { TCHAR *end; int direction =_tcstol(params[iRWDir], &end, 10); if (end == params[iRWDir] || direction < 0 || direction > 360 || (direction == 0 && rwlen <= 0)) direction = -1; else if (direction == 360) direction = 0; if (direction >= 0) new_waypoint.runway.SetDirectionDegrees(direction); } } if (iDescription < n_params) { /* * This convention was introduced by the OpenAIP * project (http://www.openaip.net/), since no waypoint type * exists for thermal hotspots. */ if (StringStartsWith(params[iDescription], _T("Hotspot"))) new_waypoint.type = Waypoint::Type::THERMAL_HOTSPOT; new_waypoint.comment = params[iDescription]; } waypoints.Append(std::move(new_waypoint)); return true; }
FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTrueType, FX_DWORD flags, int weight, int italic_angle, int WindowCP, CFX_SubstFont* pSubstFont) { if (!(flags & FXFONT_USEEXTERNATTR)) { weight = FXFONT_FW_NORMAL; italic_angle = 0; } CFX_ByteString SubstName = name; SubstName.Remove(0x20); if (bTrueType) { if (name[0] == '@') { SubstName = name.Mid(1); } } _PDF_GetStandardFontName(SubstName); if (SubstName == FX_BSTRC("Symbol") && !bTrueType) { pSubstFont->m_Family = "Chrome Symbol"; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } FX_LPCBYTE pFontData = NULL; FX_DWORD size = 0; m_pFontMgr->GetStandardFont(pFontData, size, 12); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; } if (SubstName == FX_BSTRC("ZapfDingbats")) { pSubstFont->m_Family = "Chrome Dingbats"; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; if (m_FoxitFaces[13]) { return m_FoxitFaces[13]; } FX_LPCBYTE pFontData = NULL; FX_DWORD size = 0; m_pFontMgr->GetStandardFont(pFontData, size, 13); m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[13]; } int iBaseFont = 0; CFX_ByteString family, style; FX_BOOL bHasComma = FALSE; FX_BOOL bHasHypen = FALSE; int find = SubstName.Find(FX_BSTRC(","), 0); if (find >= 0) { family = SubstName.Left(find); _PDF_GetStandardFontName(family); style = SubstName.Mid(find + 1); bHasComma = TRUE; } else { family = SubstName; } for (; iBaseFont < 12; iBaseFont ++) if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) { break; } int PitchFamily = 0; FX_BOOL bItalic = FALSE; FX_DWORD nStyle = 0; FX_BOOL bStyleAvail = FALSE; FX_BOOL bFamilyStyleIsWhole = FALSE; FX_BOOL bNextF = FALSE; if (iBaseFont < 12) { family = g_Base14FontNames[iBaseFont]; if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) { nStyle |= FX_FONT_STYLE_Bold; } if ((iBaseFont % 4) / 2) { nStyle |= FX_FONT_STYLE_Italic; } if (iBaseFont < 4) { PitchFamily |= FXFONT_FF_FIXEDPITCH; } if (iBaseFont >= 8) { PitchFamily |= FXFONT_FF_ROMAN; } } else { if (!bHasComma) { find = family.ReverseFind('-'); if (find >= 0) { style = family.Mid(find + 1); family = family.Left(find); bHasHypen = TRUE; } } if (!bHasHypen) { int nLen = family.GetLength(); FX_INT32 nRet = GetStyleType(family, TRUE); if (nRet > -1) { family = family.Left(nLen - g_FontStyles[nRet].len); if (nRet == 0) { nStyle |= FX_FONT_STYLE_Bold; } if (nRet == 1) { nStyle |= FX_FONT_STYLE_Italic; } if (nRet == 2) { nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); } } } if (flags & FXFONT_SERIF) { PitchFamily |= FXFONT_FF_ROMAN; } if (flags & FXFONT_SCRIPT) { PitchFamily |= FXFONT_FF_SCRIPT; } if (flags & FXFONT_FIXED_PITCH) { PitchFamily |= FXFONT_FF_FIXEDPITCH; } } if (!style.IsEmpty()) { int nLen = style.GetLength(); FX_LPCSTR pStyle = style; int i = 0; FX_BOOL bFirstItem = TRUE; CFX_ByteString buf; while (i < nLen) { buf = ParseStyle(pStyle, nLen, i); FX_INT32 nRet = GetStyleType(buf, FALSE); if ((i && !bStyleAvail) || (!i && nRet < 0)) { family = SubstName; iBaseFont = 12; break; } else if (nRet >= 0) { bStyleAvail = TRUE; } if (nRet == 0) { if (nStyle & FX_FONT_STYLE_Bold) { nStyle |= FX_FONT_STYLE_BoldBold; } else { nStyle |= FX_FONT_STYLE_Bold; } bFirstItem = FALSE; } if (nRet == 1) { if (bFirstItem) { nStyle |= FX_FONT_STYLE_Italic; } else { family = SubstName; iBaseFont = 12; } break; } if (nRet == 2) { nStyle |= FX_FONT_STYLE_Italic; if (nStyle & FX_FONT_STYLE_Bold) { nStyle |= FX_FONT_STYLE_BoldBold; } else { nStyle |= FX_FONT_STYLE_Bold; } bFirstItem = FALSE; } i += buf.GetLength() + 1; } } weight = weight ? weight : FXFONT_FW_NORMAL; int old_weight = weight; if (nStyle) { weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); } if (nStyle & FX_FONT_STYLE_Italic) { bItalic = TRUE; } FX_BOOL bCJK = FALSE; FX_BOOL bExact = FALSE; int Charset = FXFONT_ANSI_CHARSET; if (WindowCP) { Charset = _GetCharsetFromCodePage(WindowCP); } else if (iBaseFont == 12 && (flags & FXFONT_SYMBOLIC)) { Charset = FXFONT_SYMBOL_CHARSET; } if (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || Charset == FXFONT_HANGEUL_CHARSET || Charset == FXFONT_CHINESEBIG5_CHARSET) { bCJK = TRUE; } if (m_pFontInfo == NULL) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } family = _GetFontFamily(family, nStyle); CFX_ByteString match = MatchInstalledFonts(_TT_NormalizeName(family)); if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHypen || (bHasHypen && !bStyleAvail)))) { match = MatchInstalledFonts(_TT_NormalizeName(SubstName)); } if (match.IsEmpty() && iBaseFont >= 12) { if (!bCJK) { if (!CheckSupportThirdPartFont(family, PitchFamily)) { if (italic_angle != 0) { bItalic = TRUE; } else { bItalic = FALSE; } weight = old_weight; } } else { pSubstFont->m_bSubstOfCJK = TRUE; if (nStyle) { pSubstFont->m_WeightCJK = weight; } else { pSubstFont->m_WeightCJK = FXFONT_FW_NORMAL; } if (nStyle & FX_FONT_STYLE_Italic) { pSubstFont->m_bItlicCJK = TRUE; } } } else { italic_angle = 0; weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); } if (!match.IsEmpty() || iBaseFont < 12) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; if (!match.IsEmpty()) { family = match; } if (iBaseFont < 12) { if (nStyle && !(iBaseFont % 4)) { if ((nStyle & 0x3) == 1) { iBaseFont += 1; } if ((nStyle & 0x3) == 2) { iBaseFont += 3; } if ((nStyle & 0x3) == 3) { iBaseFont += 2; } } if (m_pFontMgr->m_ExternalFonts[iBaseFont].m_pFontData) { if (m_FoxitFaces[iBaseFont]) { return m_FoxitFaces[iBaseFont]; } m_FoxitFaces[iBaseFont] = m_pFontMgr->GetFixedFace(m_pFontMgr->m_ExternalFonts[iBaseFont].m_pFontData, m_pFontMgr->m_ExternalFonts[iBaseFont].m_dwSize, 0); if (m_FoxitFaces[iBaseFont]) { return m_FoxitFaces[iBaseFont]; } } else { family = g_Base14FontNames[iBaseFont]; } pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; } } else { if (flags & FXFONT_ITALIC) { bItalic = TRUE; } } bExact = !match.IsEmpty(); void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, family, bExact); if (bExact) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; } if (hFont == NULL) { if (bCJK) { if (italic_angle != 0) { bItalic = TRUE; } else { bItalic = FALSE; } weight = old_weight; } if (!match.IsEmpty()) { hFont = m_pFontInfo->GetFont(match); if (hFont == NULL) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } } else { if (Charset == FXFONT_SYMBOL_CHARSET) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ if (SubstName == FX_BSTRC("Symbol")) { pSubstFont->m_Family = "Chrome Symbol"; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } FX_LPCBYTE pFontData = NULL; FX_DWORD size = 0; m_pFontMgr->GetStandardFont(pFontData, size, 12); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; } else { pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); } #else pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); #endif } if (Charset == FXFONT_ANSI_CHARSET) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } int index = m_CharsetArray.Find(Charset); if (index < 0) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } else { hFont = m_pFontInfo->GetFont(m_FaceArray[index]); } } } pSubstFont->m_ExtHandle = m_pFontInfo->RetainFont(hFont); if (hFont == NULL) { return NULL; } m_pFontInfo->GetFaceName(hFont, SubstName); if (Charset == FXFONT_DEFAULT_CHARSET) { m_pFontInfo->GetFontCharset(hFont, Charset); } FX_DWORD ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); FX_DWORD font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); if(font_size == 0 && ttc_size == 0) { m_pFontInfo->DeleteFont(hFont); return NULL; } FXFT_Face face = NULL; if (ttc_size) { FX_BYTE temp[1024]; m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); FX_DWORD checksum = 0; for (int i = 0; i < 256; i ++) { checksum += ((FX_DWORD*)temp)[i]; } FX_LPBYTE pFontData; face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_size, pFontData); if (face == NULL) { pFontData = FX_Alloc(FX_BYTE, ttc_size); if (pFontData) { m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size); face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, ttc_size, ttc_size - font_size); } } } else { FX_LPBYTE pFontData; face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData); if (face == NULL) { pFontData = FX_Alloc(FX_BYTE, font_size); if (!pFontData) { m_pFontInfo->DeleteFont(hFont); return NULL; } m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size); face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, font_size, m_pFontInfo->GetFaceIndex(hFont)); } } if (face == NULL) { m_pFontInfo->DeleteFont(hFont); return NULL; } pSubstFont->m_Family = SubstName; pSubstFont->m_Charset = Charset; FX_BOOL bNeedUpdateWeight = FALSE; if (FXFT_Is_Face_Bold(face)) { if (weight == FXFONT_FW_BOLD) { bNeedUpdateWeight = FALSE; } else { bNeedUpdateWeight = TRUE; } } else { if (weight == FXFONT_FW_NORMAL) { bNeedUpdateWeight = FALSE; } else { bNeedUpdateWeight = TRUE; } } if (bNeedUpdateWeight) { pSubstFont->m_Weight = weight; } if (bItalic && !FXFT_Is_Face_Italic(face)) { if (italic_angle == 0) { italic_angle = -12; } else if (FXSYS_abs(italic_angle) < 5) { italic_angle = 0; } pSubstFont->m_ItalicAngle = italic_angle; } m_pFontInfo->DeleteFont(hFont); return face; }
static subpicture_region_t *CreateTextRegion( decoder_t *p_dec, char *psz_subtitle, int i_len, int i_sys_align ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_region_t *p_text_region; video_format_t fmt; /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_CODEC_TEXT; fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_text_region = subpicture_region_New( &fmt ); if( p_text_region != NULL ) { ssa_style_t *p_ssa_style = NULL; p_text_region->psz_text = NULL; p_text_region->psz_html = strndup( psz_subtitle, i_len ); if( ! p_text_region->psz_html ) { subpicture_region_Delete( p_text_region ); return NULL; } p_ssa_style = ParseStyle( p_sys, p_text_region->psz_html ); if( !p_ssa_style ) { int i; for( i = 0; i < p_sys->i_ssa_styles; i++ ) { if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) ) p_ssa_style = p_sys->pp_ssa_styles[i]; } } if( p_ssa_style ) { msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename ); p_text_region->p_style = text_style_Duplicate( &p_ssa_style->font_style ); p_text_region->i_align = p_ssa_style->i_align; /* TODO: Setup % based offsets properly, without adversely affecting * everything else in vlc. Will address with separate patch, * to prevent this one being any more complicated. * p_ssa_style->i_margin_percent_h; * p_ssa_style->i_margin_percent_v; */ p_text_region->i_x = p_ssa_style->i_margin_h; p_text_region->i_y = p_ssa_style->i_margin_v; } else { p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM | i_sys_align; p_text_region->i_x = i_sys_align ? 20 : 0; p_text_region->i_y = 10; } /* Look for position arguments which may override the style-based * defaults. */ SetupPositions( p_text_region, psz_subtitle ); p_text_region->p_next = NULL; } return p_text_region; }
bool WaypointReaderSeeYou::ParseLine(const TCHAR* line, const unsigned linenum, Waypoints &waypoints) { enum { iName = 0, iLatitude = 3, iLongitude = 4, iElevation = 5, iStyle = 6, iRWDir = 7, iRWLen = 8, iFrequency = 9, iDescription = 10, }; if (linenum == 0) ignore_following = false; // If (end-of-file or comment) if (StringIsEmpty(line) || StringStartsWith(line, _T("**")) || StringStartsWith(line, _T("*"))) // -> return without error condition return true; TCHAR ctemp[4096]; if (_tcslen(line) >= ARRAY_SIZE(ctemp)) /* line too long for buffer */ return false; // Skip first line if it doesn't begin with a quotation character // (usually the field order line) if (linenum == 0 && line[0] != _T('\"')) return true; // If task marker is reached ignore all following lines if (_tcsstr(line, _T("-----Related Tasks-----")) == line) ignore_following = true; if (ignore_following) return true; // Get fields const TCHAR *params[20]; size_t n_params = ExtractParameters(line, ctemp, params, ARRAY_SIZE(params), true, _T('"')); // Check if the basic fields are provided if (iName >= n_params || iLatitude >= n_params || iLongitude >= n_params) return false; Waypoint new_waypoint; // Latitude (e.g. 5115.900N) if (!ParseAngle(params[iLatitude], new_waypoint.location.latitude, true)) return false; // Longitude (e.g. 00715.900W) if (!ParseAngle(params[iLongitude], new_waypoint.location.longitude, false)) return false; new_waypoint.location.Normalize(); // ensure longitude is within -180:180 new_waypoint.file_num = file_num; new_waypoint.original_id = 0; // Name (e.g. "Some Turnpoint") if (*params[iName] == _T('\0')) return false; new_waypoint.name = params[iName]; // Elevation (e.g. 458.0m) /// @todo configurable behaviour if ((iElevation >= n_params || !ParseAltitude(params[iElevation], new_waypoint.elevation)) && !CheckAltitude(new_waypoint)) return false; // Style (e.g. 5) if (iStyle < n_params) ParseStyle(params[iStyle], new_waypoint.type); new_waypoint.flags.turn_point = true; // Frequency & runway direction/length (for airports and landables) // and description (e.g. "Some Description") if (new_waypoint.IsLandable()) { if (iFrequency < n_params) new_waypoint.radio_frequency = RadioFrequency::Parse(params[iFrequency]); // Runway length (e.g. 546.0m) fixed rwlen = fixed_minus_one; if (iRWLen < n_params && ParseDistance(params[iRWLen], rwlen) && positive(rwlen)) new_waypoint.runway.SetLength(uround(rwlen)); if (iRWDir < n_params && *params[iRWDir]) { TCHAR *end; int direction =_tcstol(params[iRWDir], &end, 10); if (end == params[iRWDir] || direction < 0 || direction > 360 || (direction == 0 && !positive(rwlen))) direction = -1; else if (direction == 360) direction = 0; if (direction >= 0) new_waypoint.runway.SetDirectionDegrees(direction); } } if (iDescription < n_params) new_waypoint.comment = params[iDescription]; waypoints.Append(new_waypoint); return true; }
FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTrueType, uint32_t flags, int weight, int italic_angle, int WindowCP, CFX_SubstFont* pSubstFont) { if (!(flags & FXFONT_USEEXTERNATTR)) { weight = FXFONT_FW_NORMAL; italic_angle = 0; } CFX_ByteString SubstName = name; SubstName.Remove(' '); if (bTrueType && name[0] == '@') SubstName = name.Mid(1); PDF_GetStandardFontName(&SubstName); if (SubstName == "Symbol" && !bTrueType) { pSubstFont->m_Family = "Chrome Symbol"; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; if (m_FoxitFaces[12]) return m_FoxitFaces[12]; const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; } if (SubstName == "ZapfDingbats") { pSubstFont->m_Family = "Chrome Dingbats"; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; if (m_FoxitFaces[13]) return m_FoxitFaces[13]; const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[13]; } int iBaseFont = 0; CFX_ByteString family; CFX_ByteString style; bool bHasComma = false; bool bHasHyphen = false; int find = SubstName.Find(",", 0); if (find >= 0) { family = SubstName.Left(find); PDF_GetStandardFontName(&family); style = SubstName.Mid(find + 1); bHasComma = true; } else { family = SubstName; } for (; iBaseFont < kExternalFontIndex; iBaseFont++) { if (family == CFX_ByteStringC(g_Base14FontNames[iBaseFont])) break; } int PitchFamily = 0; bool bItalic = false; uint32_t nStyle = 0; bool bStyleAvail = false; if (iBaseFont < kExternalFontIndex) { if ((iBaseFont % 4) == 1 || (iBaseFont % 4) == 2) nStyle |= FX_FONT_STYLE_Bold; if ((iBaseFont % 4) / 2) nStyle |= FX_FONT_STYLE_Italic; if (iBaseFont < 4) PitchFamily |= FXFONT_FF_FIXEDPITCH; if (iBaseFont >= 8) PitchFamily |= FXFONT_FF_ROMAN; } else { if (!bHasComma) { find = family.ReverseFind('-'); if (find >= 0) { style = family.Mid(find + 1); family = family.Left(find); bHasHyphen = true; } } if (!bHasHyphen) { int nLen = family.GetLength(); int32_t nRet = GetStyleType(family, true); if (nRet > -1) { family = family.Left(nLen - g_FontStyles[nRet].len); if (nRet == 0) nStyle |= FX_FONT_STYLE_Bold; else if (nRet == 1) nStyle |= FX_FONT_STYLE_Italic; else if (nRet == 2) nStyle |= (FX_FONT_STYLE_Bold | FX_FONT_STYLE_Italic); } } UpdatePitchFamily(flags, PitchFamily); } if (!style.IsEmpty()) { int nLen = style.GetLength(); const FX_CHAR* pStyle = style.c_str(); int i = 0; bool bFirstItem = true; CFX_ByteString buf; while (i < nLen) { buf = ParseStyle(pStyle, nLen, i); int32_t nRet = GetStyleType(buf, false); if ((i && !bStyleAvail) || (!i && nRet < 0)) { family = SubstName; iBaseFont = kExternalFontIndex; break; } if (nRet >= 0) { bStyleAvail = true; } if (nRet == 1) { if (bFirstItem) { nStyle |= FX_FONT_STYLE_Italic; } else { family = SubstName; iBaseFont = kExternalFontIndex; } break; } if (nRet == 0) { if (nStyle & FX_FONT_STYLE_Bold) nStyle |= FX_FONT_STYLE_BoldBold; else nStyle |= FX_FONT_STYLE_Bold; bFirstItem = false; } else if (nRet == 2) { nStyle |= FX_FONT_STYLE_Italic; if (nStyle & FX_FONT_STYLE_Bold) nStyle |= FX_FONT_STYLE_BoldBold; else nStyle |= FX_FONT_STYLE_Bold; bFirstItem = false; } i += buf.GetLength() + 1; } } weight = weight ? weight : FXFONT_FW_NORMAL; int old_weight = weight; if (nStyle) { weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); } if (nStyle & FX_FONT_STYLE_Italic) bItalic = true; int iExact = 0; int Charset = FXFONT_ANSI_CHARSET; if (WindowCP) Charset = GetCharsetFromCodePage(WindowCP); else if (iBaseFont == kExternalFontIndex && (flags & FXFONT_SYMBOLIC)) Charset = FXFONT_SYMBOL_CHARSET; bool bCJK = (Charset == FXFONT_SHIFTJIS_CHARSET || Charset == FXFONT_GB2312_CHARSET || Charset == FXFONT_HANGUL_CHARSET || Charset == FXFONT_CHINESEBIG5_CHARSET); if (!m_pFontInfo) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } family = GetFontFamily(family, nStyle); CFX_ByteString match = MatchInstalledFonts(TT_NormalizeName(family.c_str())); if (match.IsEmpty() && family != SubstName && (!bHasComma && (!bHasHyphen || (bHasHyphen && !bStyleAvail)))) { match = MatchInstalledFonts(TT_NormalizeName(SubstName.c_str())); } if (match.IsEmpty() && iBaseFont >= kExternalFontIndex) { if (!bCJK) { if (!CheckSupportThirdPartFont(family, PitchFamily)) { bItalic = italic_angle != 0; weight = old_weight; } } else { pSubstFont->m_bSubstCJK = true; if (nStyle) pSubstFont->m_WeightCJK = nStyle ? weight : FXFONT_FW_NORMAL; if (nStyle & FX_FONT_STYLE_Italic) pSubstFont->m_bItalicCJK = true; } } else { italic_angle = 0; weight = nStyle & FX_FONT_STYLE_BoldBold ? 900 : (nStyle & FX_FONT_STYLE_Bold ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); } if (!match.IsEmpty() || iBaseFont < kExternalFontIndex) { if (!match.IsEmpty()) family = match; if (iBaseFont < kExternalFontIndex) { if (nStyle && !(iBaseFont % 4)) { if ((nStyle & 0x3) == 1) iBaseFont += 1; if ((nStyle & 0x3) == 2) iBaseFont += 3; if ((nStyle & 0x3) == 3) iBaseFont += 2; } family = g_Base14FontNames[iBaseFont]; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; } } else { if (flags & FXFONT_ITALIC) bItalic = true; } iExact = !match.IsEmpty(); void* hFont = m_pFontInfo->MapFont(weight, bItalic, Charset, PitchFamily, family.c_str(), iExact); if (iExact) pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT; if (!hFont) { #ifdef PDF_ENABLE_XFA if (flags & FXFONT_EXACTMATCH) return nullptr; #endif // PDF_ENABLE_XFA if (bCJK) { bItalic = italic_angle != 0; weight = old_weight; } if (!match.IsEmpty()) { hFont = m_pFontInfo->GetFont(match.c_str()); if (!hFont) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } } else { if (Charset == FXFONT_SYMBOL_CHARSET) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \ _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_ if (SubstName == "Symbol") { pSubstFont->m_Family = "Chrome Symbol"; pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; pSubstFont->m_Charset = FXFONT_SYMBOL_CHARSET; if (m_FoxitFaces[12]) return m_FoxitFaces[12]; const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; } #endif pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); } if (Charset == FXFONT_ANSI_CHARSET) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } auto it = std::find_if(m_FaceArray.begin(), m_FaceArray.end(), [Charset](const FaceData& face) { return face.charset == static_cast<uint32_t>(Charset); }); if (it == m_FaceArray.end()) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); } hFont = m_pFontInfo->GetFont(it->name.c_str()); } } if (!hFont) return nullptr; m_pFontInfo->GetFaceName(hFont, SubstName); if (Charset == FXFONT_DEFAULT_CHARSET) m_pFontInfo->GetFontCharset(hFont, Charset); uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, kTableTTCF, nullptr, 0); uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, nullptr, 0); if (font_size == 0 && ttc_size == 0) { m_pFontInfo->DeleteFont(hFont); return nullptr; } FXFT_Face face = nullptr; if (ttc_size) face = GetCachedTTCFace(hFont, kTableTTCF, ttc_size, font_size); else face = GetCachedFace(hFont, SubstName, weight, bItalic, font_size); if (!face) { m_pFontInfo->DeleteFont(hFont); return nullptr; } pSubstFont->m_Family = SubstName; pSubstFont->m_Charset = Charset; bool bNeedUpdateWeight = false; if (FXFT_Is_Face_Bold(face)) bNeedUpdateWeight = weight != FXFONT_FW_BOLD; else bNeedUpdateWeight = weight != FXFONT_FW_NORMAL; if (bNeedUpdateWeight) pSubstFont->m_Weight = weight; if (bItalic && !FXFT_Is_Face_Italic(face)) { if (italic_angle == 0) italic_angle = -12; else if (FXSYS_abs(italic_angle) < 5) italic_angle = 0; pSubstFont->m_ItalicAngle = italic_angle; } m_pFontInfo->DeleteFont(hFont); return face; }
Settings::Settings(FXMainWindow*w, const FXString &configdir, MenuMgr*mmgr):SettingsBase() { mnumgr=mmgr; FXString tmp; reg=&(w->getApp()->reg()); style_reg=new FXSettings(); app=w->getApp(); style_file=configdir+STYLE_FILE; if (use_xdg_config()) { style_file.append(".rc"); } #ifdef FOX_1_6 // Fox-1.6 will choke reading string entries > 2000 chars, so rewrite // the styles file, in case it was written by a newer version of Fox. if (FXStat::exists(style_file)) { FXFile style_fh(style_file,FXIO::Reading); if (style_fh.isOpen()) { FXString style_data('\0', style_fh.size()+1); style_fh.readBlock((char*)style_data.text(), style_fh.size()); style_fh.close(); FXint n=style_data.contains(ENDLINE); bool toolong=false; for (FXint i=0; i<=n; i++) { if (style_data.section(ENDLINE,i).length()>1952) { toolong=true; break; } } if (toolong && style_fh.open(style_file,FXIO::Writing)) { FXint eoln=strlen(ENDLINE); for (FXint i=0; i<=n; i++) { FXString line=style_data.section(ENDLINE,i); line.trunc(1952); if (strlen(line.text())) { style_fh.writeBlock(line.text(),line.length()); } style_fh.writeBlock(ENDLINE,eoln); } style_fh.close(); } } } #endif if ( (FXStat::exists(style_file)) && (!style_reg->parseFile(style_file, true))) { FXMessageBox::error(app,MBOX_OK, _("Configuration error"), "%s \n%s\n%s", _("Failed to read settings from"), style_file.text(), SystemErrorStr() ); } ReadInt(ShowStatusBar,true); ReadInt(ShowLineNumbers,false); ReadInt(ShowToolbar,true); ReadInt(ShowWhiteSpace,false); ReadInt(ShowOutputPane,false); bool InvertColors=false; ReadInt(InvertColors,false); ColorFuncs::InvertColors(InvertColors); ReadIntRng(SplitView,0,SPLIT_NONE,SPLIT_BESIDE); ReadInt(OutputPaneHeight,64); ReadInt(SmartHome,false); ReadInt(WrapAwareHomeEnd,false); ReadIntRng(BraceMatch,BRACEMATCH_EITHER,BRACEMATCH_NONE,BRACEMATCH_AFTER); ReadInt(UseTabs,true); ReadInt(CaretPastEOL,false); ReadIntRng(TabWidth,4,1,16); ReadIntRng(IndentWidth,TabWidth,1,16); ReadIntRng(CaretWidth,1,1,3); ReadIntRng(RightEdgeColumn,80,1,1024); ReadInt(ShowRightEdge,false); ReadInt(ShowIndentGuides,false); ReadInt(ShowCaretLine,true); ReadInt(SmoothScroll,true); ReadIntRng(WheelLines,3,1,32); ReadIntRng(SearchWrap,SEARCH_WRAP_ASK,SEARCH_WRAP_NEVER,SEARCH_WRAP_ASK); ReadIntRng(SearchGui,SEARCH_GUI_BELOW,SEARCH_GUI_ABOVE,SEARCH_GUI_FLOAT); ReadIntRng(AutoIndent,AUTO_INDENT_NONE,AUTO_INDENT_NONE,AUTO_INDENT_SMART); ReadInt(SearchVerbose,true); ReadInt(SearchOptions,0); ReadInt(ZoomFactor,0); ReadIntRng(MaxFiles,128,1,999); ReadInt(PromptCloseMultiMenu,true); ReadInt(PromptCloseMultiExit,true); ReadInt(WatchExternChanges,true); ReadInt(Autosave,false); ReadIntRng(AutosaveInterval,60,15,900); ReadInt(SaveBeforeFilterSel,false); ReadInt(SaveBeforeInsCmd,false); ReadInt(SaveBeforeExecCmd,true); ReadInt(WhitespaceShowsEOL,true); ReadIntRng(DefaultFileFormat,DEFAULT_EOL_FORMAT,0,2); ReadInt(DefaultToAscii,!LocaleIsUTF8()); ReadInt(DefaultToSbcs,true); ReadIntRng(KeepFileFilter,REMEMBER_NEVER,REMEMBER_NEVER,REMEMBER_ALWAYS); if (KeepFileFilter==REMEMBER_ALWAYS) { ReadInt(FileFilterIndex,0); } else { FileFilterIndex=0; } ReadInt(FileOpenMulti,false); ReadInt(WordWrap,false); ReadInt(WrapToolbar,true); ReadIntRng(ToolbarButtonSize,1,0,2);// 0=small; 1=medium; 2=large placement=reg->existingEntry(geom_sect,"Top")?PLACEMENT_DEFAULT:PLACEMENT_SCREEN; ReadInt(Left,0); ReadInt(Top,0); ReadInt(Width,0); ReadInt(Height,0); ScreenWidth=w->getApp()->getRootWindow()->getDefaultWidth(); ScreenHeight=w->getApp()->getRootWindow()->getDefaultHeight(); if ((Width==0)&&(Height==0)) { // First run, size based on screen dimensions Width=ScreenWidth*(4.0/5.0); Height=ScreenHeight*(3.0/4.0); LIMIT_RANGE(Width,600,Width); LIMIT_RANGE(Height,400,Height); } LIMIT_RANGE(Left,0,Left); LIMIT_RANGE(Top,0,Top); LIMIT_RANGE(Width,160,Width); LIMIT_RANGE(Height,120,Height); ReadInt(Maximize,false); ReadIntRng(TabTitleMaxWidth,ScreenWidth/6,0,ScreenWidth); reg->deleteSection("LastFocused"); ReadInt(FontSize,120); ReadIntRng(FontAscent,2,0,16); ReadIntRng(FontDescent,0,0,16); if (reg->existingEntry(edit_sect,"FontName")) { ReadStr(FontName,"Fixed [Misc]"); } else { FindFont(FontName); } tmp=reg->readStringEntry(view_sect,"DocTabPosition","T"); if (tmp.empty() || !strchr("TBLR",tmp.text()[0])) { DocTabPosition='T'; } else { DocTabPosition=tmp.text()[0]; } tmp=reg->readStringEntry(view_sect,"DocTabsPacked","A"); if (tmp=="0") { tmp="U"; } else if (tmp=="1") { tmp="P"; } if (tmp.empty() || !strchr("UPA",tmp.text()[0])) { DocTabsPacked='A'; } else { DocTabsPacked=tmp.text()[0]; } ReadStr(FileFilters, default_file_filters); FileFilters.substitute("|", "\n", true); ReadStr(ShellCommand,SHELL_COMMAND); ParseStyles(style_reg, global_sect, GlobalStyle); ParseStyle(style_reg, global_sect, &WhiteSpaceStyle); ParseStyle(style_reg, global_sect, &CaretLineStyle); ParseStyle(style_reg, global_sect, &RightMarginStyle); for (LangStyle*ls=languages; ls->name; ls++) { if (ls->words) { int i; for (i=0; ls->words[i]; i++) { char buf[256]; snprintf(buf,sizeof(buf)-1, "words_%d", i+1); tmp=style_reg->readStringEntry(ls->name,buf,ls->words[i]); SetKeywordList(ls,i,tmp); } } ParseStyles(style_reg, ls->name, ls->styles); tmp=style_reg->readStringEntry(ls->name,"FileMask",ls->mask?ls->mask:""); if ( (ls->mask && (strcmp(ls->mask,tmp.text())!=0))||((ls->mask==NULL)&&(!tmp.empty())) ) { ls->mask=strdup(tmp.text()); ls->mallocs |= LANGSTYLE_MASK_ALLOCD; } tmp=style_reg->readStringEntry(ls->name,"ShebangApps",ls->apps?ls->apps:""); if ( (ls->apps && (strcmp(ls->apps,tmp.text())!=0))||((ls->apps==NULL)&&(!tmp.empty())) ){ ls->apps=strdup(tmp.text()); ls->mallocs |= LANGSTYLE_APPS_ALLOCD; } ls->tabs=(TabPolicy)(style_reg->readIntEntry(ls->name,"TabPolicy", ls->tabs)); ls->tabwidth=style_reg->readIntEntry(ls->name,"TabWidth", 0); LIMIT_RANGE(ls->tabwidth,0,16); } styles=GlobalStyle; mnumgr->ReadMenuSpecs(reg,keys_sect); mnumgr->ReadToolbarButtons(reg,tbar_sect); mnumgr->ReadPopupMenu(reg,popup_sect); ReadErrorPatterns(reg); ReadSysIncPaths(reg); }
static subpicture_region_t *CreateTextRegion( decoder_t *p_dec, char *psz_subtitle, int i_sys_align ) { decoder_sys_t *p_sys = p_dec->p_sys; subpicture_region_t *p_text_region; video_format_t fmt; /* Create a new subpicture region */ video_format_Init( &fmt, VLC_CODEC_TEXT ); fmt.i_width = fmt.i_height = 0; fmt.i_x_offset = fmt.i_y_offset = 0; p_text_region = subpicture_region_New( &fmt ); video_format_Clean( &fmt ); if( p_text_region != NULL ) { ssa_style_t *p_ssa_style = NULL; p_ssa_style = ParseStyle( p_sys, psz_subtitle ); if( !p_ssa_style ) { for( int i = 0; i < p_sys->i_ssa_styles; i++ ) { if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) ) p_ssa_style = p_sys->pp_ssa_styles[i]; } } /* Set default or user align/magin. * Style overriden if no user value. */ p_text_region->i_x = i_sys_align > 0 ? 20 : 0; p_text_region->i_y = 10; p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM | ((i_sys_align > 0) ? i_sys_align : 0); if( p_ssa_style ) { msg_Dbg( p_dec, "style is: %s", p_ssa_style->psz_stylename ); /* TODO: Setup % based offsets properly, without adversely affecting * everything else in vlc. Will address with separate patch, * to prevent this one being any more complicated. * p_ssa_style->i_margin_percent_h; * p_ssa_style->i_margin_percent_v; */ if( i_sys_align == -1 ) { p_text_region->i_align = p_ssa_style->i_align; p_text_region->i_x = p_ssa_style->i_margin_h; p_text_region->i_y = p_ssa_style->i_margin_v; } p_text_region->p_text = text_segment_NewInheritStyle( p_ssa_style->p_style ); } else { p_text_region->p_text = text_segment_New( NULL ); } /* Look for position arguments which may override the style-based * defaults. */ SetupPositions( p_text_region, psz_subtitle ); p_text_region->p_next = NULL; } return p_text_region; }