Also, make fontspec_to_str not return the address of an automatic variable.
It now has a memory leak instead.
git-svn-id: http://svn.tartarus.org/sgt/putty@2767
cda61777-01e9-0310-a592-
d414129be87e
-/* $Id: mac.c,v 1.38 2003/02/01 12:54:40 simon Exp $ */
+/* $Id: mac.c,v 1.39 2003/02/01 15:44:08 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
-FontSpec platform_default_font(char const *name)
+FontSpec platform_default_fontspec(char const *name)
{
FontSpec ret;
long smfs;
{
FontSpec ret;
long smfs;
- Str255 pname;
- static char cname[256];
if (!strcmp(name, "Font")) {
smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
if (smfs == 0)
smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
if (smfs != 0) {
if (!strcmp(name, "Font")) {
smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
if (smfs == 0)
smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
if (smfs != 0) {
- GetFontName(HiWord(smfs), pname);
- if (pname[0] == 0)
- strcpy(ret.name, "Monaco");
- ret.height = LoWord(smfs);
- p2cstrcpy(ret.name, pname);
+ GetFontName(HiWord(smfs), ret.name);
+ if (ret.name[0] == 0)
+ memcpy(ret.name, "\pMonaco", 7);
+ ret.size = LoWord(smfs);
- strcpy(ret.name, "Monaco");
- ret.height = 9;
+ memcpy(ret.name, "\pMonaco", 7);
+ ret.size = 9;
int platform_default_i(char const *name, int def)
{
int platform_default_i(char const *name, int def)
{
/* Non-raw cut and paste of line-drawing chars works badly on the
* current Unix stub implementation of the Unicode functions.
/* Non-raw cut and paste of line-drawing chars works badly on the
* current Unix stub implementation of the Unicode functions.
char *filename_to_str(Filename fn)
{
char *filename_to_str(Filename fn)
{
+ /* FIXME: Memory leak! */
+
+ return dupstr(fn.path);
}
int filename_equal(Filename f1, Filename f2)
}
int filename_equal(Filename f1, Filename f2)
#include <Palettes.h>
#include <UnicodeConverter.h>
#include <Palettes.h>
#include <UnicodeConverter.h>
-#include <stdio.h> /* for FILENAME_MAX */
-
-struct Filename {
- char path[FILENAME_MAX];
-};
-#define f_open(filename, mode) ( fopen((filename).path, (mode)) )
-
-struct FontSpec {
- char name[64];
- int isbold;
- int height;
-};
-
#define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY')
#define INTERNAL_CREATOR FOUR_CHAR_CODE('pTTI')
#define SESS_TYPE FOUR_CHAR_CODE('Sess')
#define PUTTY_CREATOR FOUR_CHAR_CODE('pTTY')
#define INTERNAL_CREATOR FOUR_CHAR_CODE('pTTI')
#define SESS_TYPE FOUR_CHAR_CODE('Sess')
-/* $Id: macstore.c,v 1.13 2003/02/01 12:54:40 simon Exp $ */
+/* $Id: macstore.c,v 1.14 2003/02/01 15:44:08 ben Exp $ */
/*
* macstore.c: Macintosh-specific impementation of the interface
/*
* macstore.c: Macintosh-specific impementation of the interface
{
char *settingname;
FontSpec ret;
{
char *settingname;
FontSpec ret;
- if (!read_setting_s(handle, name, ret.name, sizeof(ret.name)))
+ if (!read_setting_s(handle, name, tmp, sizeof(tmp)))
- settingname = dupcat(name, "IsBold", NULL);
- ret.isbold = read_setting_i(handle, settingname, -1);
+ c2pstrcpy(ret.name, tmp);
+ settingname = dupcat(name, "Face", NULL);
+ ret.face = read_setting_i(handle, settingname, 0);
- if (ret.isbold == -1) return 0;
- if (ret.charset == -1) return 0;
settingname = dupcat(name, "Height", NULL);
settingname = dupcat(name, "Height", NULL);
- ret.height = read_setting_i(handle, settingname, INT_MIN);
+ ret.size = read_setting_i(handle, settingname, 0);
- if (ret.height == INT_MIN) return 0;
+ if (ret.size == 0) return 0;
*result = ret;
return 1;
}
*result = ret;
return 1;
}
void write_setting_fontspec(void *handle, const char *name, FontSpec font)
{
char *settingname;
void write_setting_fontspec(void *handle, const char *name, FontSpec font)
{
char *settingname;
- write_setting_s(handle, name, font.name);
- settingname = dupcat(name, "IsBold", NULL);
- write_setting_i(handle, settingname, font.isbold);
+ p2cstrcpy(tmp, font.name);
+ write_setting_s(handle, name, tmp);
+ settingname = dupcat(name, "Face", NULL);
+ write_setting_i(handle, settingname, font.face);
- settingname = dupcat(name, "Height", NULL);
- write_setting_i(handle, settingname, font.height);
+ settingname = dupcat(name, "Size", NULL);
+ write_setting_i(handle, settingname, font.size);
typedef void *Context; /* FIXME */
typedef void *Context; /* FIXME */
+#include <MacTypes.h>
+#include <stdio.h> /* for FILENAME_MAX */
+
+struct Filename {
+ char path[FILENAME_MAX];
+};
+#define f_open(filename, mode) ( fopen((filename).path, (mode)) )
+
+/* Suspiciously similar to an ICFontRecord */
+struct FontSpec {
+ short size;
+ Style face;
+ Str255 name;
+};
+
/*
* On the Mac, Unicode text copied to the clipboard has U+2028 line separators.
* Non-Unicode text will have these converted to CR along with the rest of the
/*
* On the Mac, Unicode text copied to the clipboard has U+2028 line separators.
* Non-Unicode text will have these converted to CR along with the rest of the
-/* $Id: macterm.c,v 1.62 2003/02/01 12:54:40 simon Exp $ */
+/* $Id: macterm.c,v 1.63 2003/02/01 15:44:08 ben Exp $ */
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
/*
* Copyright (c) 1999 Simon Tatham
* Copyright (c) 1999, 2002 Ben Harris
static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
static void mac_initfont(Session *s) {
static UnicodeToTextFallbackUPP uni_to_font_fallback_upp;
static void mac_initfont(Session *s) {
FontInfo fi;
TextEncoding enc;
OptionBits fbflags;
SetPort(s->window);
FontInfo fi;
TextEncoding enc;
OptionBits fbflags;
SetPort(s->window);
- c2pstrcpy(macfont, s->cfg.font.name);
- GetFNum(macfont, &s->fontnum);
+ GetFNum(s->cfg.font.name, &s->fontnum);
- TextFace(s->cfg.font.isbold ? bold : 0);
- TextSize(s->cfg.font.height);
+ TextFace(s->cfg.font.face);
+ TextSize(s->cfg.font.size);
GetFontInfo(&fi);
s->font_width = CharWidth('W'); /* Well, it's what NCSA uses. */
s->font_ascent = fi.ascent;
GetFontInfo(&fi);
s->font_width = CharWidth('W'); /* Well, it's what NCSA uses. */
s->font_ascent = fi.ascent;
&s->font_stdnumer, &s->font_stddenom);
mac_workoutfontscale(s, s->font_width * 2,
&s->font_widenumer, &s->font_widedenom);
&s->font_stdnumer, &s->font_stddenom);
mac_workoutfontscale(s, s->font_width * 2,
&s->font_widenumer, &s->font_widedenom);
- TextSize(s->cfg.font.height * 2);
+ TextSize(s->cfg.font.size * 2);
mac_workoutfontscale(s, s->font_width * 2,
&s->font_bignumer, &s->font_bigdenom);
mac_workoutfontscale(s, s->font_width * 2,
&s->font_bignumer, &s->font_bigdenom);
- TextSize(s->cfg.font.height);
+ TextSize(s->cfg.font.size);
if (!s->cfg.bold_colour) {
TextFace(bold);
s->font_boldadjust = s->font_width - CharWidth('W');
if (!s->cfg.bold_colour) {
TextFace(bold);
s->font_boldadjust = s->font_width - CharWidth('W');
if (mac_gestalts.encvvers != 0 &&
UpgradeScriptInfoToTextEncoding(kTextScriptDontCare,
kTextLanguageDontCare,
if (mac_gestalts.encvvers != 0 &&
UpgradeScriptInfoToTextEncoding(kTextScriptDontCare,
kTextLanguageDontCare,
- kTextRegionDontCare, macfont,
+ kTextRegionDontCare, s->cfg.font.name,
&enc) == noErr &&
CreateUnicodeToTextInfoByEncoding(enc, &s->uni_to_font) == noErr) {
if (uni_to_font_fallback_upp == NULL)
&enc) == noErr &&
CreateUnicodeToTextInfoByEncoding(enc, &s->uni_to_font) == noErr) {
if (uni_to_font_fallback_upp == NULL)
no_encv:
s->uni_to_font = NULL;
no_encv:
s->uni_to_font = NULL;
+ p2cstrcpy(cfontname, s->cfg.font.name);
s->font_charset =
charset_from_macenc(FontToScript(s->fontnum),
GetScriptManagerVariable(smRegionCode),
s->font_charset =
charset_from_macenc(FontToScript(s->fontnum),
GetScriptManagerVariable(smRegionCode),
- mac_gestalts.sysvers, s->cfg.font.name);
+ mac_gestalts.sysvers, cfontname);
}
mac_adjustsize(s, s->term->rows, s->term->cols);
}
mac_adjustsize(s, s->term->rows, s->term->cols);
stsc->scrpStyleTab[0].scrpAscent = s->font_ascent;
stsc->scrpStyleTab[0].scrpFont = s->fontnum;
stsc->scrpStyleTab[0].scrpFace = 0;
stsc->scrpStyleTab[0].scrpAscent = s->font_ascent;
stsc->scrpStyleTab[0].scrpFont = s->fontnum;
stsc->scrpStyleTab[0].scrpFace = 0;
- stsc->scrpStyleTab[0].scrpSize = s->cfg.font.height;
+ stsc->scrpStyleTab[0].scrpSize = s->cfg.font.size;
stsc->scrpStyleTab[0].scrpColor.red = 0;
stsc->scrpStyleTab[0].scrpColor.green = 0;
stsc->scrpStyleTab[0].scrpColor.blue = 0;
stsc->scrpStyleTab[0].scrpColor.red = 0;
stsc->scrpStyleTab[0].scrpColor.green = 0;
stsc->scrpStyleTab[0].scrpColor.blue = 0;
void do_text(Context ctx, int x, int y, char *text, int len,
unsigned long attr, int lattr) {
Session *s = ctx;
void do_text(Context ctx, int x, int y, char *text, int len,
unsigned long attr, int lattr) {
Session *s = ctx;
struct do_text_args a;
RgnHandle textrgn, saveclip;
char mactextbuf[1024];
struct do_text_args a;
RgnHandle textrgn, saveclip;
char mactextbuf[1024];
a.lattr = lattr;
switch (lattr & LATTR_MODE) {
case LATTR_NORM:
a.lattr = lattr;
switch (lattr & LATTR_MODE) {
case LATTR_NORM:
- TextSize(s->cfg.font.height);
+ TextSize(s->cfg.font.size);
a.numer = s->font_stdnumer;
a.denom = s->font_stddenom;
break;
case LATTR_WIDE:
a.numer = s->font_stdnumer;
a.denom = s->font_stddenom;
break;
case LATTR_WIDE:
- TextSize(s->cfg.font.height);
+ TextSize(s->cfg.font.size);
a.numer = s->font_widenumer;
a.denom = s->font_widedenom;
break;
case LATTR_TOP:
case LATTR_BOT:
a.numer = s->font_widenumer;
a.denom = s->font_widedenom;
break;
case LATTR_TOP:
case LATTR_BOT:
- TextSize(s->cfg.font.height * 2);
+ TextSize(s->cfg.font.size * 2);
a.numer = s->font_bignumer;
a.denom = s->font_bigdenom;
break;
}
SetPort(s->window);
TextFont(s->fontnum);
a.numer = s->font_bignumer;
a.denom = s->font_bigdenom;
break;
}
SetPort(s->window);
TextFont(s->fontnum);
- if (s->cfg.font.isbold || (attr & ATTR_BOLD) && !s->cfg.bold_colour)
+ style = s->cfg.font.face;
+ if ((attr & ATTR_BOLD) && !s->cfg.bold_colour)
style |= bold;
if (attr & ATTR_UNDER)
style |= underline;
style |= bold;
if (attr & ATTR_UNDER)
style |= underline;