public void displayScaledPage(HalfBook halfbook)
{
Rect textRect = halfbook.getTextRect();
Rect bookRect = halfbook.getBookRect();
half_code_style.fontSize = (int) (code_style.fontSize * bookRect.width / Screen.width);
float fontScale = half_code_style.fontSize / ((float) code_style.fontSize);
//float fontScale = bookRect.width / Screen.width;
//GUI.SetNextControlName("SpellbookPage");
GUI.DrawTexture(bookRect,currentPage().texture);
//if (GUI.Button(bookRect,currentPage().texture))
// halfbook.setFocus();
//GUI.SetNextControlName("ReferenceCode");
GUILayout.BeginArea(textRect);
scroll_position = GUILayout.BeginScrollView (scroll_position, GUILayout.Width(textRect.width), GUILayout.Height(textRect.height)); // Should vary the size of the last rect by how much text we have??
foreach (Tuple<Rect, Texture2D> tup in (new Highlight()).highlightPage(currentPage().code)) {
//since we changed the font size, need to rescale the highlighting
Rect h = tup.Item1;
h.x = (h.x) * fontScale;
h.y = (h.y+2) /23 * half_code_style.lineHeight - 2*fontScale;
h.width *= fontScale;
h.height *= fontScale;
GUI.DrawTexture(h, tup.Item2);
}
GUILayout.TextArea(currentPage().code, half_code_style);
//GUILayout.Label(currentPage().code, code_style);
//GUILayout.Box(currentPage().code, code_style);
GUILayout.EndScrollView();
GUILayout.EndArea();
}