diff --git a/graf2d/cocoa/src/FontCache.mm b/graf2d/cocoa/src/FontCache.mm index 8e75b69c4bc983dba96edcc0a806493563d6398e..cc24c0b9c9f3f4662311d4f588510b4d5de8fd43 100644 --- a/graf2d/cocoa/src/FontCache.mm +++ b/graf2d/cocoa/src/FontCache.mm @@ -55,9 +55,14 @@ const CFStringRef fixedFontNames[FontCache::nPadFonts] = //______________________________________________________________________________ -CTFontCollectionRef CreateFontCollection(const X11::XLFDName &xlfd) +CTFontCollectionRef CreateFontCollection(const X11::XLFDName &/*xlfd*/) { - CTFontCollectionRef ctCollection = 0; + CTFontCollectionRef ctCollection = CTFontCollectionCreateFromAvailableFonts(0); + if (!ctCollection) + ::Error("CreateFontCollection", "CTFontCollectionCreateFromAvailableFonts failed"); + + return ctCollection; +/* CTFontCollectionRef ctCollection = 0; if (xlfd.fFamilyName == "*") ctCollection = CTFontCollectionCreateFromAvailableFonts(0);//Select all available fonts. else { @@ -90,7 +95,7 @@ CTFontCollectionRef CreateFontCollection(const X11::XLFDName &xlfd) } - return ctCollection; + return ctCollection;*/ } //______________________________________________________________________________ @@ -115,6 +120,23 @@ void GetWeightAndSlant(CTFontDescriptorRef fontDescriptor, X11::XLFDName &newXLF //Let's ask for a weight and pixel size. const Util::CFScopeGuard<CFDictionaryRef> traits((CFDictionaryRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontTraitsAttribute)); if (traits.Get()) { + if (CFNumberRef symbolTraits = (CFNumberRef)CFDictionaryGetValue(traits.Get(), kCTFontSymbolicTrait)) { + uint32_t val = 0; + CFNumberGetValue(symbolTraits, kCFNumberIntType, &val); + if (val & kCTFontItalicTrait) + newXLFD.fSlant = X11::kFSItalic; + else + newXLFD.fSlant = X11::kFSRegular; + + if (val & kCTFontBoldTrait) + newXLFD.fWeight = X11::kFWBold; + else + newXLFD.fWeight = X11::kFWMedium; + } + + /* + //The code below is wrong - using it, I can not identify bold or italic and always have + //only medium/regular. if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(traits.Get(), kCTFontWeightTrait)) { double val = 0.; if (CFNumberGetValue(weight, kCFNumberDoubleType, &val)) @@ -126,6 +148,7 @@ void GetWeightAndSlant(CTFontDescriptorRef fontDescriptor, X11::XLFDName &newXLF if (CFNumberGetValue(slant, kCFNumberDoubleType, &val)) newXLFD.fSlant = val > 0. ? X11::kFSItalic : X11::kFSRegular; } + */ } } @@ -156,7 +179,7 @@ void CreateXLFDString(const X11::XLFDName &xlfd, std::string &xlfdString) if (xlfd.fWeight == X11::kFWBold) xlfdString += "-bold"; else - xlfdString += "-*"; + xlfdString += "-normal"; if (xlfd.fSlant == X11::kFSItalic) xlfdString += "-i"; @@ -266,16 +289,19 @@ char **FontCache::ListFonts(const X11::XLFDName &xlfd, int maxNames, int &count) if (!GetFamilyName(font, familyName)) continue; - //I do not check family name: if xlfd.fFamilyName is '*', all font names fit, - //if it's a special name - collection is created using this name. + + if (xlfd.fFamilyName != "*" && xlfd.fFamilyName != &familyName[0]) + continue; + newXLFD.fFamilyName = &familyName[0]; GetWeightAndSlant(font, newXLFD); + //Check weight and slant. - if (newXLFD.fWeight != xlfd.fWeight) + /*if (newXLFD.fWeight != xlfd.fWeight) continue; if (newXLFD.fSlant != xlfd.fSlant) - continue; + continue;*/ if (xlfd.fPixelSize) {//Size was requested. GetPixelSize(font, newXLFD); diff --git a/gui/gui/src/TGCanvas.cxx b/gui/gui/src/TGCanvas.cxx index c8fb0d26763d07259612b5e65000d84cb39203ae..b27f280843912f6864b2e7a983585958087a60f5 100644 --- a/gui/gui/src/TGCanvas.cxx +++ b/gui/gui/src/TGCanvas.cxx @@ -792,13 +792,16 @@ void TGContainer::SetPageDimension(UInt_t w, UInt_t h) void TGContainer::DoRedraw() { // Redraw content of container in the viewport region. - +#ifdef R__HAS_COCOA + DrawRegion(0, 0, GetWidth(), GetHeight()); +#else if (!fExposedRegion.IsEmpty()) { DrawRegion(fExposedRegion.fX, fExposedRegion.fY, fExposedRegion.fW, fExposedRegion.fH); fExposedRegion.Empty(); } +#endif } //______________________________________________________________________________ diff --git a/gui/gui/src/TGFontDialog.cxx b/gui/gui/src/TGFontDialog.cxx index 582991cfe74e2441433c5796b2fb2f8b0ffb09c3..bcc7b53cab203466d39a6f17445d822d6fc19610 100644 --- a/gui/gui/src/TGFontDialog.cxx +++ b/gui/gui/src/TGFontDialog.cxx @@ -180,9 +180,10 @@ TGFontDialog::TGFontDialog(const TGWindow *p, const TGWindow *t, fFontNames = new TGListBox(vf, kFDLG_FONTNAMES); fFontNames->Resize(120, fFontNames->GetDefaultHeight()); - if (gVirtualX->InheritsFrom("TGX11")) { + if (gVirtualX->InheritsFrom("TGX11") || gVirtualX->InheritsFrom("TGCocoa")) { fFontNames->Connect("Selected(char*)", "TGFontDialog", this, "UpdateStyleSize(char*)"); } + fFontNames->Associate(this); vf->AddFrame(fFontNames, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); @@ -580,6 +581,13 @@ void TGFontDialog::UpdateStyleSize(const char *family) Bool_t x11 = gVirtualX->InheritsFrom("TGX11"); Bool_t all_sizes = !x11; Bool_t all_styles = !x11; + + // + if (gVirtualX->InheritsFrom("TGCocoa")) { + all_sizes = kTRUE; + all_styles = kFALSE; + } + int szn = 0; fFontSizes->AddEntry("12", szn++);