The font override button in the subtitles edit box can now modify font size, italics, bold and underline as well as font face

Originally committed to SVN as r102.
This commit is contained in:
Rodrigo Braz Monteiro 2006-02-21 22:46:18 +00:00
parent 493ebbcbb1
commit aa6ef96527
2 changed files with 21 additions and 16 deletions

View File

@ -42,6 +42,7 @@ Please visit http://aegisub.net to download latest version
- Fixed some internal workings, which should make Aegisub use considerably less RAM (especially for large Karaoke files, 3-4x less RAM usage was measured with a 9 MB file). (AMZ)
- Aegisub will now dump the stack to stack.txt when it crashes with a fatal exception, which might or might not work. (AMZ)
- Audio display in SSA mode will no longer ignore clicks if it wasn't focused (AMZ)
- The font override button in the subtitles edit box can now modify font size, italics, bold and underline as well as font face (no strikeout, as wx does not provide an interface to access that data). (AMZ)
= 1.09 beta - 2006.01.16 ===========================

View File

@ -1027,8 +1027,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
// Default value
wxColour startcolor;
wxString startfont;
int startfontpoint;
wxFont startfont;
bool isColor = false;
bool isFont = false;
bool isPos = false;
@ -1054,9 +1053,11 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
isFlag = true;
}
else if (tagname == _T("\\fn")) {
alttagname = _T("\\fs");
startfont = style->font;
startfontpoint = style->fontsize;
startfont.SetFaceName(style->font);
startfont.SetPointSize(style->fontsize);
startfont.SetWeight(style->bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
startfont.SetStyle(style->italic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
startfont.SetUnderlined(style->underline);
isFont = true;
}
else if (tagname == _T("\\c")) {
@ -1086,13 +1087,16 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
if (override) {
for (size_t j=0;j<override->Tags.size();j++) {
tag = override->Tags.at(j);
if (tag->Name == tagname || tag->Name == alttagname) {
if (tag->Name == tagname || tag->Name == alttagname || tagname == _T("\\fn")) {
if (isColor) startcolor = tag->Params.at(0)->AsColour();
if (isFont) {
if (tag->Name == tagname) startfont = tag->Params.at(0)->AsText();
else startfontpoint = tag->Params.at(0)->AsInt();
}
if (isFlag) state = tag->Params.at(0)->AsBool();
if (isFont) {
if (tag->Name == _T("\\fn")) startfont.SetFaceName(tag->Params.at(0)->AsText());
if (tag->Name == _T("\\fs")) startfont.SetPointSize(tag->Params.at(0)->AsInt());
if (tag->Name == _T("\\b")) startfont.SetWeight((tag->Params.at(0)->AsInt() > 0) ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
if (tag->Name == _T("\\i")) startfont.SetStyle(tag->Params.at(0)->AsBool() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
if (tag->Name == _T("\\u")) startfont.SetUnderlined(tag->Params.at(0)->AsBool());
}
}
}
}
@ -1125,15 +1129,15 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos)
// Choose font
if (isFont) {
// Pick from dialog
wxFont origFont;
origFont.SetFaceName(startfont);
origFont.SetPointSize(startfontpoint);
wxFont font = wxGetFontFromUser(this,origFont);
wxFont font = wxGetFontFromUser(this,startfont);
if (!font.Ok()) return;
// Generate insert string
if (font.GetFaceName() != startfont) insert = tagname + font.GetFaceName();
if (font.GetPointSize() != startfontpoint) insert += alttagname + wxString::Format(_T("%i"),font.GetPointSize());
if (font.GetFaceName() != startfont.GetFaceName()) insert = _T("\\fn") + font.GetFaceName();
if (font.GetPointSize() != startfont.GetPointSize()) insert += _T("\\fs") + wxString::Format(_T("%i"),font.GetPointSize());
if (font.GetWeight() != startfont.GetWeight()) insert += _T("\\b") + wxString::Format(_T("%i"),font.GetWeight() == wxFONTWEIGHT_BOLD ? 1 : 0);
if (font.GetStyle() != startfont.GetStyle()) insert += _T("\\i") + wxString::Format(_T("%i"),font.GetStyle() == wxFONTSTYLE_ITALIC ? 1 : 0);
if (font.GetUnderlined() != startfont.GetUnderlined()) insert += _T("\\u") + wxString::Format(_T("%i"),font.GetUnderlined() ? 1 : 0);
if (insert.IsEmpty()) return;
}